我有以下批处理命令可以使用 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"
如何更改此批处理命令以使用
dtd
打开所有文件下分机 "D:\data"
文件夹 ?我尝试了下面的代码,但它不起作用
REM Open all the static content files
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\\*.dtd"
最佳答案
您可以使用 FOR
命令:
FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]
Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree. If no directory specification is specified after /R then the current directory is assumed. If set is just a single period (.) character then it will just enumerate the directory tree.
在您的情况下,这应该有效:
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"
关于batch-file - 在 Notepad++ 中打开某种类型的所有文件的批处理命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27525175/