TheShaner
asked on
Batch file looping
Can someone show me how to work loops in a DOS batch file? At the most basic level, I could give the following example.
Loop using a counter.. A do while if you will. I guess an easy example would be something like this.
Create 50 directories. All with the same name, only with a number at the end of it. And stop when I hit 50
server1
server2
server3
etc.
Also, does anyone know any good reasources for learning this kind of stuff? I am pretty handy in writing batch files, but would really like to take things to the next level and add some real complexity to them.
Thanks,
Shaner
Loop using a counter.. A do while if you will. I guess an easy example would be something like this.
Create 50 directories. All with the same name, only with a number at the end of it. And stop when I hit 50
server1
server2
server3
etc.
Also, does anyone know any good reasources for learning this kind of stuff? I am pretty handy in writing batch files, but would really like to take things to the next level and add some real complexity to them.
Thanks,
Shaner
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
More usefull stuff in if /? and cmd/? for starters.
Steve
Steve
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In addition to those I've got these bookmarked too:
http://labmice.techtarget.com/articles/batchcmds.htm
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
http://labmice.techtarget.com/articles/batchcmds.htm
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
the most basic loop would be this:
:START
(whatever you want to be looped)
GOTO START
:START
(whatever you want to be looped)
GOTO START
thanks for the answer, hope it helped.
Steve
Steve
for /l %%a in (1,1,50) do mkdir server%%a
for /? gives a mine of information as does set /?
I learned the more complex stuff watching here to be honest.
Steve