Computing.Net > Forums > Programming > Batch For DO(list of if exist set)?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch For DO(list of if exist set)?

Reply to Message Icon

Name: Anime
Date: January 3, 2008 at 11:02:11 Pacific
OS: Windows XP
CPU/Ram: AMD 64 X2 Dual 4200
Comment:

Hi, I'm trying to do a batch file
where need to do a

For %%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



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: January 4, 2008 at 02:29:51 Pacific
Reply:

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.


0

Response Number 2
Name: Anime
Date: January 13, 2008 at 01:51:45 Pacific
Reply:

wow i learn something new.
thanks klint, i will try out!

I love DVD


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Plot a graph Barcode translator for C+...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch For DO(list of if exist set)?

DOS - batch variables www.computing.net/answers/programming/dos-batch-variables/15058.html

Adding a list of numbers www.computing.net/answers/programming/adding-a-list-of-numbers/17355.html

batch: extract 1st char of dir name www.computing.net/answers/programming/batch-extract-1st-char-of-dir-name/15648.html