0

Windows バッチ ファイルのディレクトリ構造を再帰的にトラバースするにはどうすればよいですか?

作成者がすべてのディレクトリをテキスト ファイルにリストし、テキスト ファイルを読み取ってディレクトリに入力し、繰り返す例を除いて、インターネット上で例を見つけられませんでした。

4

1 に答える 1

1

FOR /Rループをチェックしてください。

FOR /R [[ドライブ:]パス] %変数 IN (セット) DO コマンド [コマンド パラメータ]

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

出力を与えます:

C:\dummy\.
C:\dummy\foo\.
C:\dummy\foo\bar\.
于 2013-11-07T11:58:42.647 に答える