jBuildz17
jBuildz17

Reputation: 13

How do I check if a file exists inside a certain directory in Batch?

How would I go about making a program that scans for a certain file inside a certain directory, not on the C:\ drive?

I know that IF EXIST does find a certain file, but I want it to to only try to find a certain file inside a certain directory, not on the C:\ as a whole.

Upvotes: 1

Views: 178

Answers (1)

AjV Jsy
AjV Jsy

Reputation: 6075

Add the full path and filename to the IF EXIST and it will only check in that specified folder.

IF EXIST "C:\folder\folder2\file.ext" ...

Edited by Magoo - added quotes which are required if the full path contains spaces or some other characters

Upvotes: 1

Related Questions