for /r %%i in (*) do (echo %%i)
Results in
%%i was unexpected at this time
Why?
%%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.
If you are getting this error on your IF statement check if used or not your double equals to compare your variable. Eg. This throws "=1 was unexpected at this time." To correct this add another equals sign.
A batch file can be commented using either two colons :: or a REM command. The main difference is that the lines commented out using the REM command will be displayed during execution of the batch file (can be avoided by setting @echo off ) while the lines commented out using :: , won't be printed.
In the Windows command line, when trying to copy, move, or rename a file or directory with a space, you may get the "The syntax of the command is incorrect" error message. This error message is generated when the Windows command line does not understand the syntax of the command because it is not formatted properly.
You must be trying to run the command from the command line and not from within a batch file. Use a single % instead of two when running from the command line.
for /r %i in (*) do (echo %i)
Type HELP FOR
from the command line and read the 3rd paragraph.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With