looping

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

looping

#1 Post by scienceguru1.bat » 19 Jan 2011 20:49

how can i make a batch file loop a set amount of times?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: looping

#2 Post by aGerman » 20 Jan 2011 12:41

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

scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

Re: looping

#3 Post by scienceguru1.bat » 20 Jan 2011 14:33

what do the different fields do & how do i them

ChickenSoup
Posts: 79
Joined: 13 Dec 2010 10:32

Re: looping

#4 Post by ChickenSoup » 21 Jan 2011 08:11

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)

Post Reply