Manny90
Manny90

Reputation: 9

Multiple FOR and one DO for batch file?

Could someone explain to me why this fails?

FOR %l IN (1 2 3 4 5 6 7 8 9) FOR %a IN (temp\*.upp) DO upp1.exe c%l %a

Any help would be great.

Upvotes: 0

Views: 57

Answers (1)

paxdiablo
paxdiablo

Reputation: 882626

You're missing a required do, as with:

for %x in (1,2) do for %y in (a,b) do echo %x%y

which outputs:

1a
1b
2a
2b

If you leave out the first do (as you have done), all you get is:

for was unexpected at this time.

You need, for your particular case:

FOR %l IN (1 2 3 4 5 6 7 8 9) DO FOR %a IN (temp*.upp) DO upp1.exe c%l %a
REM                           ==

Upvotes: 4

Related Questions