|
Answer» Hi everybody, I am chaitanya, I want the SYNTAX of a particular command. Let me explain my problem.
I have two files located in two different directories. I want to check the existence of those two files. If those two files exist in the specified location "hi" should be echoed else the prompt should echo bye.
It should look some thing like this:
if exist c:\play.wav c:\lyrics\play.txt ( echo hi ) else ( echo bye ). I tried this but failed. I am able to check the existence if one file at a time. I want the command to be executed if those two files exist.
Can ANYBODY PLEASE help me?
Thank you all in advance.CODE: [Select]SET flag=0 if exist c:\play.wav set flag=1 if exist c:\lyrics\play.txt set /a flag +=1 if %flag% equ 2 ( echo hi ) else ( echo bye ) Thank you Salmon.Alternatives:
Code: [Select]set bothexist=no if exist c:\play.wav if exist c:\lyrics\play.txt set bothexist=yes if "%bothexist%"=="yes" ( echo hi ) else ( echo bye )
Code: [Select]set bothexist=no
if exist c:\play.wav ( if exist c:\lyrics\play.txt ( set bothexist=yes ) )
if "%bothexist%"=="yes" ( echo hi command(s) to execute if both exist ) else ( echo bye command(s) to execute if both do not exist )
|