Batch file 批处理命令,用于在记事本++;
我使用以下批处理命令打开扩展名为Batch file 批处理命令,用于在记事本++;,batch-file,filesystems,Batch File,Filesystems,我使用以下批处理命令打开扩展名为dtd的文件 REM Open all the static content files "C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder1\File1.dtd" "C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder1\File2.dtd" "C:\Program Files (x86)\Notepad++\n
dtd
的文件
REM Open all the static content files
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder1\File1.dtd"
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder1\File2.dtd"
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder2\File1.dtd"
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder2\File2.dtd"
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder3\File1.dtd"
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\folder3\File2.dtd"
如何更改此批处理命令以打开“D:\data”
文件夹下扩展名为dtd
的所有文件
我尝试了下面的代码,但它不工作
REM Open all the static content files
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\\*.dtd"
您可以使用
FOR
命令:
FOR/R[[drive:]path]%(设置)DO命令[命令参数]中的变量
遍历以[drive:]路径为根的目录树,执行FOR
树的每个目录中的语句。如果没有目录
在/R之后指定规范,则当前目录为
假定的。如果集合只是一个单周期(.)字符,那么它
将只枚举目录树
在您的情况下,这应该有效:
FOR /R d:\data %a IN (*.dtd) DO "C:\Program Files (x86)\Notepad++\notepad++.exe" "%a"
如果需要从批处理文件运行此操作,请使用%%a
如果要使用多个扩展名,可以用空格分隔这些扩展名
FOR /R d:\data %a IN (*.dtd *.xml *.xslt) DO "C:\Program Files (x86)\Notepad++\notepad++.exe" "%a"
您可能还希望以以下方式写入批处理文件:
set command=C:\Program Files (x86)\Notepad++\notepad++.exe
FOR /R d:\data %%a IN (*.dtd) DO %command% %%a
如果不希望打开上一个会话中的文件,请添加-nosession
参数。
(此处为.bat
文件中的dtd
扩展名示例)
有可能在in(set)部分同时包含几个fileending吗?@Kaiserludi是的,事实证明是可能的,我在回答中添加了这个选项。
for /R %%x in (*.dtd) do (
start "" "C:\Program Files\Notepad++\notepad++.exe" -nosession "%%x"
)