single per (.) in for loop batch

smiLe February 10, 2009 at 13:47:17
Specs: Windows XP
If a single period (.) character in for loop batch file means it will just enumerate the directory tree. So what if I just want it to go into 1 subfolder? Thanks.

See More: single per (.) in for loop batch

Report •

February 10, 2009 at 15:11:22
I think you are referring to the FOR /R command, as in

for /r %%d in (.) do ...

which will indeed traverse the whole tree. To enumerate only the subfolders of the current directory, use this:

for /d %%d in (*) do ...

To enumerate all the files in these subfolders, use a nested for loop:

for /d %%d in (*) do (
   for %%f in ("%%d\*") do (
      echo "%%d\%%f"

Report •

February 11, 2009 at 11:24:57
Got it. thanks

Report •

Related Solutions

Ask Question