Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"was unexpected at this time."

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?

like image 848
Ricardo Moura Avatar asked Oct 14 '11 15:10

Ricardo Moura


People also ask

Was unexpected at this time batch 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.

How do I comment in a batch file?

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.


1 Answers

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.

like image 100
paxdiablo Avatar answered Oct 04 '22 09:10

paxdiablo