Quantcast
Channel: For Loop counting from 1 to n in a windows bat script - Server Fault
Viewing all articles
Browse latest Browse all 4

For Loop counting from 1 to n in a windows bat script

$
0
0

I need to run a windows command n times within a bat script file. I know how to do this in various programming languages but cannot manage to get it right on the windows command line :-(

I would expect something like either

for(int i = 0; i < 100; i++) {
   // do something
}

or even this (though not entirely seriously)

1.upto(100, {
   // do something
}) 

Thanks!

EDIT

I can write a program in java, perl, c or whatever that will generate a bat script that looks like this

for %%N in (1 2 3 4 5 6 7 8 9 10 11 12) do echo %%N

and so on. Or even "better":

echo 1
echo 2
echo 3
echo 4
echo 5
echo 6
echo 7
echo 8
echo 9
echo 10
echo 11
echo 12

and then execute it... But the thing is that I need a concise way to specify a range of numbers to iterate through within the script.

Thanks!


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images