Computing.Net > Forums > Programming > For /l

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.

For /l

Reply to Message Icon

Name: AJ (by William Jimenez)
Date: November 25, 2008 at 05:20:24 Pacific
OS: XP
CPU/Ram: Dell
Comment:

I am aware that I'm about to ask what is to all of you the most dumb question you've seen here but for the sake of learning I'm going to do it.

The more I use the FOR command the more uses I find for but,can any one give me a real life scenario of how to use the FOR /L command, other than making the commmand prompt count from 1 to 1000 really fast I do't see how I would use it in real life.

I warned you it was dumb.

Thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: BatchFreak
Date: November 25, 2008 at 05:42:50 Pacific
Reply:

In a batch file which uses the set command it can be very useful.

SET /p you=Do you like cheese? y/n
IF /I %you%==n ECHO you suck

I only Batch if possible, 2000 more lines of code, oh well.


0

Response Number 2
Name: AJ (by William Jimenez)
Date: November 25, 2008 at 05:52:12 Pacific
Reply:

Well first of all let me say that couldn't agree more with your statement.

Second of all I could acomplish that without FOR /L

Like this

SET /p you=Do you like cheese? y/n
If %you%==n ECHO You Suck!

I thought it would have to do with like a counter so that I can say run this loop for n times then do/stop etc.

Thanks.


0

Response Number 3
Name: Holla
Date: November 25, 2008 at 08:40:55 Pacific
Reply:

AJ,

Couple of places where I found it useful is
1. To rename files that have sequential numbers - needs to mass renamed.


for /l %i in (1,1,9) do if exist animie*%i* ren animie*%i* animations%i.mpg

2. Get a series of files from the web.\
for /l %i in (1,1,9) do wget ftp://ftp.site.com/filename.part0%i
for /l %i in (9,1,99) do wget ftp://ftp.site.com/filename.part%i

you get the idea.
[edited with examples later]
--
Holla.


0

Response Number 4
Name: AJ (by William Jimenez)
Date: November 25, 2008 at 08:45:54 Pacific
Reply:

Thanks Holla.


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: For /l

FOR /L loop using set command www.computing.net/answers/programming/for-l-loop-using-set-command/18705.html

FOR Statment, MAX using Variable www.computing.net/answers/programming/for-statment-max-using-variable/8971.html

Finite Loops for a batch file www.computing.net/answers/programming/finite-loops-for-a-batch-file/15200.html