Thursday, December 16, 2010

Legacy DOS Script: Loop Over Directories

Simple little script to loop over all sub-directories:
FOR /D %%f IN (".\*") DO ECHO %%f

2 comments:

Richard said...

Exactly what I was looking for, thanks! I found, however, that at least on Windows 7 x64, I need to use only a single %, so:

FOR /D %f IN (".\*") DO ECHO %f

Michael Gillespie said...

You need to use two percentage signs (%%) if you are doing this in a batch file, otherwise one (%) works if you are doing it straight from a command line.

There was an error in this gadget