🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3644

Re: Batch problem

#3644
From: Lasse Reichstein Nielsen
Date: Fri, 13 Nov 1992 09:27
60 lines
1618 bytes
au240@cleveland.Freenet.Edu (Ari Pitkanen) writes:



>How do I pass '%%f' to 'DoIt'?  This approach don't work.

>---
>:Main
>cd scene
>for %%f in (*.*) do goto DoIt   REM copy filename to %%f
>goto End

>:DoIt
>cd..
>trace scene\%%f                 REM %%f don't contain the filename :(
>copy scene\%%f traced
>del scene\%%f
>cd..
>goto Main

>:End
>cd..

>---

>Ari

>-- 
>Ari Pitkanen : au240@cleveland.freenet.edu

Your problem is that COMMAND.COM  completes it's FOR command before continuing
 to process the rets of the .BAT file. That means, in a directory with fx. 20
 files 20 GOTO DoIt's are executed within the FOR statement, and on exit from
 the FOR, the 'program-counter' has been changed to DoIt
That is: ONLY THE *LAST* GOTO IS ACTUALLY PERFORMED!
And the %%f variable exists only within the FOR-statement, hence your problem!

A solution is to break your file into two:


:Main
cd scene
for %%f in (*.*) do call doit.bat %%f
cd ..
 
and :

<doit.bat>

cd..
trace scene\%1  
copy scene\%1 traced
del scene\%1
cd scene

<end>

This should do the trick!

					Spot / u920666@daimi.aau.dk
Technical Details
Message-ID: <1992Nov13.092729.27529@daimi.aau.dk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!dkuug!daimi!u920666
References: <1dualbINN52t@usenet.INS.CWRU.Edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!dkuug!daimi!u920666
From: u920666@daimi.aau.dk (Lasse Reichstein Nielsen)
Subject: Re: Batch problem
Message-ID: <1992Nov13.092729.27529@daimi.aau.dk>
Sender: u920666@daimi.aau.dk (Lasse Reichstein Nielsen)
Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
References: <1dualbINN52t@usenet.INS.CWRU.Edu>
Date: Fri, 13 Nov 92 09:27:29 GMT
Lines: 64