Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I'm trying to do a batch file
where need to do aFor %%A in (1, 2, 3, 4, 5, 6) DO(
if exisit "filename1" set var1= -par1 "filename"excecute programe with parameter.exe)
but i couldn't seems to be able to get the "if exist.. set" working inside "FOR in DO"
does anyone knows a way?
currently this state:
FOR %%A in (%VAXVA_PGC_RANGE%) DO (
IF exist "%VAXVA_PROJECT%\VAXVA_DEMUX_PGC2\AudioFile_A0.wav" set VAXVA_AUD01= -a1 "%VAXVA_PROJECT%\VAXVA_DEMUX_PGC2\AudioFile_A0.wav" -a1lang %VAXVA_AUD01_LANG%
IF exist "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_80.ac3" set VAXVA_AUD01= -a1 "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_80.ac3" -a1lang %VAXVA_AUD01_LANG%
IF exist "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_A1.wav" set VAXVA_AUD02= -a2 "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_A1.wav" -a2lang %VAXVA_AUD02_LANG%
IF exist "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_81.ac3" set VAXVA_AUD02= -a2 "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_81.ac3" -a2lang %VAXVA_AUD02_LANG%
IF exist "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_A2.wav" set VAXVA_AUD03= -a3 "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_A2.wav" -a3lang %VAXVA_AUD03_LANG%
IF exist "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_82.ac3" set VAXVA_AUD03= -a3 "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_82.ac3" -a3lang %VAXVA_AUD03_LANG%
set VAXVA_DIYAUD=%VAXVA_AUD01% %VAXVA_AUD02% %VAXVA_AUD03%
"%VAXVA_TOOLS%\BatchMux.exe" -d "%VAXVA_PROJECT%\VAXVA_MUX_PGC%%A" -muxman "%VAXVA_TOOLS%\MuxMan" -l "%VAXVA_PROJECT%\VAXVA_DEMUX_PGC%%A\BatchMux.log" %VAXVA_PALETTE% -mxp "%VAXVA_PROJECT%\VAXVA_DEMUX_PGC%%A\BatchMux.mxp" -v "%VAXVA_PROJECT%\VAXVA_DEMUX_PGC%%A\VideoFile.m2v" %VAXVA_DIYVID_MODE% %VAXVA_DIYAUD% %VAXVA_DIYSUP% -cellfr "%VAXVA_PROJECT%\VAXVA_DEMUX_PGC%%A\Celltimes.txt"
)I love DVD

I think your problem is that when you do %var% on a line inside a for loop, it does a literal translation. But this translation is not redone each time through the loop. The interpreter sees the for ... do (...) and takes all that in as if it were one long line. Thus, it does the variable substitution just once. You want it to do the substitutions each time through the loop. You can achieve that using "delayed expansion", using ! instead of %. You need to enable this feature first, by putting this line at the start:
setlocal EnableDelayedExpansion
And then do this:
IF exist "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_80.ac3" set VAXVA_AUD01= -a1 "%VAXVA_PROJECT%\VAXVA_DEMUX\AudioFile_80.ac3" -a1lang !VAXVA_AUD01_LANG!
Note that I've kept %VAXVA_PROJECT% using the % characters because it doesn't vary, so it's ok to translate that just once. But !VAXVA_AUD01_LANG! needs the ! characters because it changes in the loop.

![]() |
Plot a graph
|
Barcode translator for C+...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |