views:

939

answers:

2

In a windows batch file, is there a way to traverse a folder/subfolders hierarchy doing some action on each file?

+2  A: 

Yes, you can do this using the for command with the /r switch, e.g.:

for /r %%f in (*) do echo %%f

See also this question for an example.

Helen
+1  A: 

You can use the FOR command with the /r switch, which will walk the directory tree executing whatever you specify in the DO statement on each directory. There you can nest another FOR statement, using a dir /b *.* in the SET block.

akf