batch-file - 在 Notepad++ 中打开某种类型的所有文件的批处理命令

标签 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++\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/

相关文章:

git - 在 PHPStorm 中提交 GIT 之前运行外部工具

batch-file - IF语句使用延迟扩展?

Python 文件名/路径解析错误的希伯来语编码(使用 optparse 库)

php - 如何从我的 Laravel 项目中的公共(public)图像的 URL 中删除/存储?

c# - 如何指定 createfilew 函数获取未缓存的结果?

batch-file - FOR递归期间如何将文件保存到当前位置

windows - 使用批处理文件在单个文件中写入多行

windows - CreateProcess 能够执行批处理文件,但文档说明相反

SQL - 将非空邻接列表转换为路径

VBA 如何获取当前用户应用程序数据文件夹的路径?