Batch that will run only if another file exists.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
silent
Posts: 44
Joined: 28 Oct 2011 14:40

Batch that will run only if another file exists.

#1 Post by silent » 22 Nov 2011 12:43

Hi,how to make a batch file that will run only if another file will exist? I think it should be something like IF ELSE but i dont know how to make it.Example : when i run file "batch.bat" and if file "aaaa" (without any extension) will be in same folder as the batch.bat file will run and go to :MENU,but when there will not be "aaaa" file,it will show text "COULD NOT FIND 'aaaa' ABORT."

aGerman
Expert
Posts: 4713
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch that will run only if another file exists.

#2 Post by aGerman » 22 Nov 2011 13:13

Code: Select all

@echo off
if not exist "aaaa" (
  echo COULD NOT FIND 'aaaa' ABORT.
  pause>NUL
  goto :eof
)
:MENU
echo your stuff here ...
pause

Regards
aGerman

Post Reply