for loop in DOS batch
|
Original Message
|
Name: Adrian
Date: November 10, 2001 at 15:24:38 Pacific
Subject: for loop in DOS batch |
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
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Tin Rabbit
Date: November 10, 2001 at 15:38:23 Pacific
|
Reply: (edit) 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?
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Adrian
Date: November 11, 2001 at 01:46:23 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Laurence
Date: November 20, 2001 at 01:36:29 Pacific
|
Reply: (edit)
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.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: