Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF EXIST

Status
Not open for further replies.

gust1480

Programmer
Mar 19, 2002
148
PH
Hi! am trying to use a IF EXIST in my batch file and I created a sample batch to test this on how to use it. But somehow it doesn't work. can somebody please tell me what I'm doing wrong here.

echo off

if exist c:\batch jobs\ps_change_order.sql (
echo file exist
)
if not exist c:\batch jobs\ps_change_order.sql (
echo file does not exist
)
:end
echo End of batch program.

the result when I execute this is..

file exist
The system cannot find the path specified
file does not exist
End of batch program

 
try this:

IF EXIST c:\batch jobs\ps_change_order.sql (
ECHO File Exists
) ELSE (
ECHO File does not exist
)

:END
ECHO End of batch

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top