I'm running this command on a batch file:
for %I in (*.txt *.doc) do copy %I c:\test2
...and it keeps returning:
I was unexpected at this time.
What is the cause of this error?
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.
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 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