Double file double loop

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ac90254
Posts: 1
Joined: 23 Mar 2011 22:47

Double file double loop

#1 Post by ac90254 » 23 Mar 2011 23:16

Hello everyone,
I have a group of files *.bat and *.txt that are required to run in pairs (1 bat, 1 txt). I've been trying to call the batch and execute the command for the txt file in the same loop but I am having some troubles figuring out how to use variables and loop everything out.
Here is an example of the files:

SE-POS-W05-20110323054226.bat
SE-POS-W05-20110323054226.txt
US-POS-F10-20110323054156.bat
US-POS-F10-20110323054156.txt

Please find here the code that I tried to put together:

Code: Select all

FOR %%G IN (C:\alx\*.*) DO (
call *.bat %%G
doupdate IMPORT_POS %%G %POSCAL%
)


If I was running the above from the command line for each pair, I first
run the bat file, then run the following command with the txt file "doupdate IMPORT_POS name of the txt file %POSCAL%"

Your advice will be greatly appreciated!!

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Double file double loop

#2 Post by aGerman » 25 Mar 2011 15:57

You should only search for one of the file types.

Code: Select all

for /f "delims=" %%G in ('dir /a-d /b "C:\alx\*.txt"') do (
  call "%%~dpnG.bat" "%%~fG"
  doupdate IMPORT_POS "%%~fG" %POSCAL%
)


Regards
aGerman

Post Reply