Computing.Net > Forums > Programming > Batch loop with counter

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 with counter

Reply to Message Icon

Name: ryanpete
Date: April 2, 2007 at 12:03:04 Pacific
OS: Xp Sp2
CPU/Ram: 2.99/512
Product: Dell/Optiplex GX520
Comment:

I need to create a bat that asks user "how many time do you want to run" then it executes :loop that many times, I tried this but I can't find away to add 1 to %count% each time it loops,
any help would be great!!
Thanks,

@ECHO OFF
ECHO HOW MANY
set/p Counter=
set count=0
CLS
if %counter%==%count% GOTO PWD_END
:loop
echo test
pause
goto loop


:PWD_END
pause



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: April 2, 2007 at 12:12:21 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

set /p X=how many time do you want to run
:loop
set /a N+=1
if !N! gtr !X! goto :eof
echo your task goes here
goto :loop



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

M2



0

Response Number 2
Name: ryanpete
Date: April 2, 2007 at 12:45:24 Pacific
Reply:

Works great thanks alot


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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 with counter

read file content using batch loop www.computing.net/answers/programming/read-file-content-using-batch-loop/17010.html

Batch script with for loop in it www.computing.net/answers/programming/batch-script-with-for-loop-in-it/16875.html

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