Page 1 of 1

looping

Posted: 19 Jan 2011 20:49
by scienceguru1.bat
how can i make a batch file loop a set amount of times?

Re: looping

Posted: 20 Jan 2011 12:41
by aGerman
This can be done by FOR /L.

Code: Select all

@echo off &setlocal
for /l %%i in (1,1,10) do (
  echo iteration # %%i
)
pause

Regards
aGerman

Re: looping

Posted: 20 Jan 2011 14:33
by scienceguru1.bat
what do the different fields do & how do i them

Re: looping

Posted: 21 Jan 2011 08:11
by ChickenSoup

Code: Select all

for /?


Code: Select all

FOR /L %variable IN (start,step,end) DO command [command-parameters]

    The set is a sequence of numbers from start to end, by step amount.
    So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would
    generate the sequence (5 4 3 2 1)