"was unexpected at this time."
If you're running within a batch/cmd file, you need to double the %
markers:
for %%i in (*.txt *.doc) do copy %%i c:\test2
The single %
variant only works from the command line.
If being run from a batch file, variables need to be denoted with two percent signs, like %%I
, only from the command line you use one
I ran across a case where I was getting this error from a file that was named *.cmd. The error arose when I tried to access the first argument to the batch command:
if %1 EQU ""
Once I put quotes around the symbol for the first argument, the warning message went away:
if "%1" EQU ""