DOS Question: How do I create batch script which runs in a loop?

AmdInside

Golden Member
Jan 22, 2002
1,355
0
76
I am hoping someone can help me create a simple script. I would like to create a simple DOS batch file which calls a program name to run for 30 times. At the end of the 30 times, the loop stops. Basically, there is a benchmark I need to run 30 times over and over again. I don't want to manually execute it each time so I would like to create a batch file to run the program over and over again for 30 times. Thank you.
 

dman

Diamond Member
Nov 2, 1999
9,110
0
76
Create two files:

file1.bat with all the commands you need to run

go.bat with 'file1.bat' listed in there 30x.


I don't think there's an easy way to do for loops in dos. I would say it's possible, as I'm pretty sure I've seen it but it wasn't very straight forward.
 

Jzero

Lifer
Oct 10, 1999
18,834
1
0
set i=0
:loopTop
<Command>
set /a i=%i%+1
if %i% LSS 30 (goto loopTop) else (goto EOF)
:EOF

The else part might be screwy, but you could leave that out.
Otherwise, I think that should do ya.