Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am on DOS trying to find out whether a file/folder exists or not.

EXIST could be used in batch, but it is not available on the command-line:

C:\Users\WIN7PR~1>EXIST C:\Users
'EXIST' is not recognized as an internal or external command, operable program or batch file.
share|improve this question

3 Answers 3

up vote 3 down vote accepted

You can use a simple

DIR C:\User
share|improve this answer
Thanks! That seems to work for both folders and files. –  Nicolas Raoul Jan 25 '13 at 9:24

Just put if on the front :)

if exist C:\Users echo It exists!
share|improve this answer
Returns: C:\Users was unexpected at this time. –  Vaccano Aug 25 '14 at 20:27

You can use type command, it will return the contents of a text file without opening it, and for a directory it will return: Access is denied.

If the file or directory is not available you get the message: The system cannot find the file specified.

So for example:

C:\>type c:\temp
Access is denied.

C:\>type c:\example.txt
Some example content in a text file

C:\>type c:\doesnotexist
The system cannot find the file specified.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.