Computing.Net > Forums > Programming > [Batch] Loop for x times

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

[Batch] Loop for x times

Reply to Message Icon

Name: biatche
Date: July 25, 2008 at 04:54:23 Pacific
OS: dos
CPU/Ram: 1mb
Product: 286
Comment:

I wanna loop a few commands for like 500 times, how do I do this? Do I use IF or FOR?

.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 25, 2008 at 05:57:13 Pacific
Reply:

Much depends on the version of DOS.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: hExus
Date: August 18, 2008 at 18:21:09 Pacific
Reply:

I don't know if this will help you... but still.

@echo off
set _number=0

:start
if %_number%==500 goto end
echo %_number%
set /a _number +=1
goto start

:end
echo it works~!
pause>nul

it adds +1 to '_number' and when it reaches 500 it jumps to the :end
P.S. it will display numbers only till the 499 count, cuz after it reaches 500 it will jump to the end and skip the echo %_number% part... But you knew that right ;D ?


0

Response Number 3
Name: Mechanix2Go
Date: August 18, 2008 at 19:18:51 Pacific
Reply:

Sure, but not in DOS.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: Judago
Date: September 8, 2008 at 02:44:08 Pacific
Reply:

I know this is a really old thread but......

for %a in (1,2,3,4,5) do for %b in (1,2,3,4,5,6,7,8,9,10) do for %c in (1,2,3,4,5,6,7,8,9,10) do command

[edit]
I just realised you can't nest for statements in most true dos os's(it's close to 127 characters anyway). Sorry for misleading you, maybe spreading it out to multiple lines would help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


To change sheets of excel... date math: the saga conti...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: [Batch] Loop for x times

Variables in For loops, Batch www.computing.net/answers/programming/variables-in-for-loops-batch/17037.html

Need help on Batch file for Shutdow www.computing.net/answers/programming/need-help-on-batch-file-for-shutdow/16424.html

Simple Batch Loop www.computing.net/answers/programming/simple-batch-loop/16647.html