如何以递归方式遍历Windows批处理文件中的目录结构?
我没有在互联网上找到任何示例,除非作者列出文本文件中的所有目录,然后读取文本文件并进入目录并重复。
答案 0 :(得分:1)
查看FOR /R
循环。
FOR / R [[drive:] path]%变量IN(设置)DO命令[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.
一个例子:
C:\>md dummy
C:\>cd dummy
C:\dummy>md foo
C:\dummy>md foo\bar
C:\dummy>for /r %i in (.);do @echo %i
givs输出:
C:\dummy\.
C:\dummy\foo\.
C:\dummy\foo\bar\.