如何通过Notepad ++外部命令将脚本文件放入控制台? [英] How do get my script file to console via Notepad++ external command?

查看:137
本文介绍了如何通过Notepad ++外部命令将脚本文件放入控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Notepad ++创建脚本并从菜单运行->打开当前目录cmd打开活动文件。效果很好,结果是:

I am using Notepad++ for creating scripts and opening my active files from menu "Run" -> "Open current dir cmd". This works fine and the result is:

c:\scripts>

我想要的是我当前正在使用的文件名,以便可以尝试测试它马上。在脚本中,我使用参数定义输入和输出文件。因此,脚本不应在打开时运行,而应将脚本键入控制台:

What I would like to have is the filename that I am working on currently so that I could try testing it right away. In my scripts I use parameters to define input and output files. Therefore the script shouldn't be run while opening, rather to have the script typed into console:

c:\scripts>edit_text.pl

然后我将手动添加所需的输入和输出文件

I would then add manually the needed input and output files

c:\scripts>edit_text.pl input.txt output.txt

如何在记事本++运行功能中实现此功能?

当前在shortcuts.xml中定义为

Currently it is defined in shortcuts.xml as

cmd /K cd $(CURRENT_DIRECTORY)

我怀疑是这样的:

cmd /K cd $(CURRENT_DIRECTORY) $(FILE_NAME)

问题是,这将执行文件名。我想让它在控制台上等待我的操作。

The problem is that this will "execute" the filename as well. I would like to have it waiting on the console for my actions.

预先感谢!

推荐答案

最后的代码行将把CD和脚本调用视为一个命令。然后与和& 分开应该会有所帮助。

The final code line would mean the CD and the script invocation being treated as one command. Separating then with && should help.

cmd /K cd $(CURRENT_DIRECTORY) && $(FILE_NAME)

但是,这将使CD执行命令。我不知道有什么方法可以输入命令但不能执行。

However, that would do the CD then execute the command. I do not know of any way to enter a command but not execute it.

一个糟糕的解决方案将使用下面的命令。您可以复制并粘贴echoed命令,然后添加所需的任何参数。在窗口上设置快速编辑模式将使复制和粘贴更快。

A poor solution would use the command below. You could copy and paste the echoed command then add in any parameters needed. Setting "Quick edit" mode on the window would make the copy and paste quicker.

cmd /K cd $(CURRENT_DIRECTORY) && ECHO $(FILE_NAME)






我采用了其他方式我自己的脚本的一种方法,尽管它们没有我需要输入的参数。编辑文件(但不使用Notepad ++,因为它会在文件退出之前覆盖文件):


I have adopted a different approach for my own scripts although they do not have parameters that I need to enter. Edit the file (but not with Notepad++ as it overwrites the file just before it exits):

C:\Users\AdrianHHH\AppData\Roaming\Notepad++\shortcuts.xml

我在< UserDefinedCommands> 部分:

<NotepadPlus>
    ... unchanged
    <UserDefinedCommands>
        ... unchanged
        <Command name="Open containing folder" Ctrl="no" Alt="no" Shift="no" Key="0">explorer $(CURRENT_DIRECTORY)</Command>
        <Command name="Open current dir cmd" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /K cd /d $(CURRENT_DIRECTORY)</Command>
        <Command name="Run as command" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /C &quot;cd /d $(CURRENT_DIRECTORY) &amp;&amp; $(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="Explorer with selection" Ctrl="no" Alt="no" Shift="no" Key="0">explorer $(CURRENT_WORD)</Command>
    </UserDefinedCommands>
    ... unchanged
</NotepadPlus>

这篇关于如何通过Notepad ++外部命令将脚本文件放入控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆