为/R
循环文件(递归子文件夹)
句法
FOR /R [[drive:]path] %%parameter IN (set) DO command
钥匙
drive:path : The folder tree where the files are located.
set : A set of one or more files. Wildcards must be used.
If (set) is a period character (.) then FOR will
loop through every folder.
command : The command(s) to carry out, including any
command-line parameters.
%%parameter : A replaceable parameter:
in a batch file use %%G (on the command line %G)
此命令从 [drive:] 路径开始向下遍历文件夹树,并对每个匹配文件执行 DO 语句。
如果未指定 [drive:]path,它们将默认为当前 drive:path。
与 FOR 命令的其他一些变体不同,您必须在“集合”中包含通配符(* 或?)才能获得一致的返回结果。在许多情况下,您可以通过添加单个字符通配符来解决此问题,例如,如果您正在遍历多个文件夹以查找确切的文件名 myfile.txt,您可以改为指定myfile.t?t
http://ss64.com/nt/for_r.html