1

I need to write a batch file that repeats the same command (that takes a parameter) for each of three variable values already defined in the batch file. I want to loop over the variable values.

I'm pretty open minded to what the syntax looks like, as long as I don't have to duplicate/repeat in the code the command that needs to happen for each value.

1 Answer 1

3

You're looking for the FOR command:
http://www.robvanderwoude.com/for.php

FOR %A IN (list) DO command [ parameters ]

For example, this command will run on your computer and print out 1,2,3:

FOR %? IN (1 2 3) DO ECHO %?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .