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
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
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:
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.
Summary: I have a text file with a list of files. I want to create a batch program that loops thru all the files in this text file and executes a DOS command on each file. Batch File #1 contains the following...
Summary: YES!!! YES!!! YES!!! I'm glad to see some one else using FOR, it is a wonderful command and it will save you a LOT of time. FOR %%[variable] IN (set) DO [command & params] For will process a comm...