Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For loop in batch file error: Do was unexpected at this time

Tags:

batch-file

I am trying to execute following command using batch file:

for /f %i in (D:\random\servers.txt) DO (d:\utils\tail -60 \\%i\c$\Windows\windowsUpdate.log | d:\utils\grep "updates detected" & set tx1234=%i)

It works when being invoked on its own in command prompt but as soon as I would save it within batch file it fails with the message

Do was unexpected at this time

Any ideas?

like image 832
Jacek Jagielski Avatar asked Jul 18 '13 14:07

Jacek Jagielski


1 Answers

in batch use %%i, whereas in command line use %i

like image 187
Loïc MICHEL Avatar answered Nov 25 '22 13:11

Loïc MICHEL