批处理命令在Notepad ++中打开某个类型的所有文件 [英] Batch command to open all files of a certain type in Notepad++

查看:415
本文介绍了批处理命令在Notepad ++中打开某个类型的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下批处理命令打开 dtd 扩展名的文件。

  REM打开所有静态内容文件
C:\程序文件(x86)\Notepad ++ \ notepad ++。exeD:\data\folder1\File1.dtd
C:\程序文件(x86)\Notepad ++ \\\
otepad ++。exeD:\data\ folder1 \File2.dtd
C:\ Program Files(x86)\Notepad ++ \\\
otepad ++。exeD:\data\folder2\File1.dtd
C:\程序文件(x86)\Notepad ++ \\\
otepad ++。exeD:\data\folder2\File2.dtd
C:\程序文件(x86)\Notepad ++ \\\
otepad ++。exeD:\data\folder3\File1.dtd
C:\程序文件(x86)\Notepad ++ \\\
otepad ++。exeD:\data \folder3\File2.dtd

如何更改此批处理命令以打开所有文件 dtd 扩展名在D:\data文件夹下?



我尝试了下面的代码,但它不起作用

  REM Open al l静态内容文件
C:\程序文件(x86)\Notepad ++ \\\
otepad ++。exeD:\data\\ * .dtd
FOR
命令来创建一个名为的命令:


lock $ $ b $ p $ FOR $ R变量[[drive:] path]%变量IN(设置)DO命令[参数]



以[drive:]路径为根目录树,在树的每个目录中执行FOR
语句。如果在/ R之后没有指定目录
规范,那么当前目录是假定的
。如果设置为单个句点(。)字符,那么它
将只是枚举目录树。


在你的情况这应该工作:

  FOR / R d:\data%a IN(* .dtd)DOC:\ Program Files(x86)\Notepad ++ \\\
otepad ++。exe%a

使用 %% a 如果你需要从一个批处理文件中运行它的话

如果你想使用多个扩展名,用空格

  FOR / R d:\data%a IN(* .dtd * .xml * .xslt)DO C:\ Program Files(x86)\Notepad ++ \\\
otepad ++。exe%a


I have the following batch command to open files with dtd extension.

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"

How do I change this batch command to open all files with dtd extension under "D:\data" folder ?

I tried the below code but it does not work

REM Open all the static content files
"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\data\\*.dtd"

解决方案

You can use the FOR command:

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.

In your case this should work:

FOR /R d:\data %a IN (*.dtd) DO "C:\Program Files (x86)\Notepad++\notepad++.exe" "%a"

Use %%a if you need to run this from a batch file

If you want to use multiple extensions you can separate those with a space

FOR /R d:\data %a IN (*.dtd *.xml *.xslt) DO "C:\Program Files (x86)\Notepad++\notepad++.exe" "%a"

这篇关于批处理命令在Notepad ++中打开某个类型的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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