Reputation: 2206
I am mostly familiar with bash scripting not dos. So I have this command in a batch file I know is iterating over all the files in a directory. But I want to know what /r and %% mean. (i know %%i is referring to each file)
for /r %%i in (*) do ( echo %%i )
Upvotes: 3
Views: 20229
Reputation: 2942
the above command actually is incorrect. the /r switch expects a root path to iterate, eg. for /r . %i in (*) ...
or for /r c:\xyz %i ...
the %i is the replaceable variable in the for loop. (you can use a-z and a few other characters). the % is akin to the $ in bash.
note: use %i on the command line, but you need to double the % in a batch file.
Upvotes: 2
Reputation: 1876
/r
- iterate through the folder and all subfolders, i.e. recursively.
%%I
- placeholder for a path/filename
The above command simply lists all files in the current folder and all subfolders.
Upvotes: 3