stopping a batch file if a file isn't found

Y

yawnmoth

I'd like to write a batch file that'll stop executing if a file isn't
found when doing a 'dir'. Unfortunately, I'm not really sure how to
do this. Any ideas?
 
D

duke

I'd like to write a batch file that'll stop executing if a file isn't
found when doing a 'dir'. Unfortunately, I'm not really sure how to
do this. Any ideas?

Use exists test as below:

if not exist C:\MyFile
goto :EOJ
:EOJ
 
P

Pegasus \(MVP\)

yawnmoth said:
I'd like to write a batch file that'll stop executing if a file isn't
found when doing a 'dir'. Unfortunately, I'm not really sure how to
do this. Any ideas?

if not exist "d:\My Files\test.txt" goto :eof

You do not need a label "eof" - it is a predefined label.
 
C

Colon Terminus

yawnmoth said:
I'd like to write a batch file that'll stop executing if a file isn't
found when doing a 'dir'. Unfortunately, I'm not really sure how to
do this. Any ideas?

Read up on "If Exist".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top