Reputation: 61
I wrote (using knowledge from Internet) script (batch file) to remove all folders and files inside a folder.
DEL /F /Q /S C:\commonfiles\*
for /D %%i in ("C:\commonfiles\*") do RD /S /Q "%%i"
I just don't know what %%i means. Is it like i++ in C++?
Upvotes: 6
Views: 64735
Reputation: 57272
In this case FOR /D
iterates trough all directories in C:\commonfiles\
and on each iteration the current directory is accessible with %%i variable. It's a special variable that is valid only in FOR command context. In command prompt you'll need to use:
for /D %i in ("C:\commonfiles\*") do RD /S /Q "%i"
For more info FOR /?
or SS64.COM
Upvotes: 1
Reputation: 613262
%%i
is simply the loop variable. This is explained in the documentation for the for
command, which you can get by typing for /?
at the command prompt.
The fact that a double percent sign is used in a batch file is discussed in these links:
Upvotes: 10