Page 1 of 1

Double file double loop

Posted: 23 Mar 2011 23:16
by ac90254
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!!

Re: Double file double loop

Posted: 25 Mar 2011 15:57
by aGerman
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