Alex Rivera | Logout

How to traverse folder tree/subtrees in a windows batch file?

Asked 2009-08-20T18:16:03.340
17

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

Edit
Report

1 Answer

4

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.

answered 2009-08-20T18:32:28.313

Your Answer