Computing.Net > Forums > Disk Operating System > for loop in DOS batch

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 loop in DOS batch

Reply to Message Icon

Name: Adrian
Date: November 10, 2001 at 15:24:38 Pacific
Comment:

This program once worked, but under Windows 98 it won't attach a number to '%1', any ideas?

:echo off
for /L %%c IN (1, 1, 10) DO call :work %%c
goto :eof
:work
del C:\Phd\Bispec\file%1.dat
goto :eof

:eof



Sponsored Link
Ads by Google

Response Number 1
Name: Tin Rabbit
Date: November 10, 2001 at 15:38:23 Pacific
Reply:


1. The lines after work lable belong in a separate batch file, called work.bat
2. The jumps to lables shouldn't have the preceding colon, only the lables themselves.
3. I don't think commas are allowed as separators inside the for-in parentheses.
In other words, I think the for statement should read as follows: :
for %%c in (1 1 10) do call work %%c
4. I've never heard of the /L switch for a for statement. Is that something new?


0

Response Number 2
Name: Adrian
Date: November 11, 2001 at 01:46:23 Pacific
Reply:

Thanks, all those tips worked, but if I can't use commas in the FOR statement how do I get DOS to repeat the work.bat file 100 times?

Also I'm getting a sharing violation when I try to TYPE a file created by the batch program, but I'm sure it's not open elsewhere is this a known problem? Thanks again.


0

Response Number 3
Name: Laurence
Date: November 20, 2001 at 01:36:29 Pacific
Reply:

Batfiles: The DOS batch file programming handbook & tutorial

You are attempting to run a NT batch
in DOS. That's like trying to mix water
and oil. Forget about it and write a
new batch.


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 Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: for loop in DOS batch

Question on Using FOR %%I in () DO www.computing.net/answers/dos/question-on-using-for-i-in-do-/13990.html

File Size in DOS Batch file www.computing.net/answers/dos/file-size-in-dos-batch-file/3105.html

Dos Batch commands www.computing.net/answers/dos/dos-batch-commands/5683.html