Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Batch For DO(list of if exist set)?

Original Message
Name: Anime
Date: January 3, 2008 at 11:02:11 Pacific
Subject: Batch For DO(list of if exist set)?
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


Report Offensive Message For Removal


Response Number 1
Name: klint
Date: January 4, 2008 at 02:29:51 Pacific
Subject: Batch For DO(list of if exist set)?
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 2
Name: Anime
Date: January 13, 2008 at 01:51:45 Pacific
Subject: Batch For DO(list of if exist set)?
Reply: (edit)
wow i learn something new.
thanks klint, i will try out!

I love DVD


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

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

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC