Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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 %?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.