-2

Batch file in Windows 7.

I want to know how to test for a path + file name with an extension, if it exists or not.

I have tried if exists "myfile.ext" It seems not to see the file.

Your help is appreciated.

1 Answer 1

1

The correct command is EXIST, not "exists".

From if /?:

EXIST filename    Specifies a true condition if the specified filename
                  exists.

Example:

if exist "myfile.txt" echo Found!

And you can just add a path as needed:

if exist "c:\Some folder\myfile.txt" echo Found!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .