Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the "if exist" command work in Windows batch scripts?

In Windows batch scripts, usually we can find if exist xxx or if not exist xxx.

Does this search all files in the computer, or any specific folder or path, for the xxx specified?

like image 673
hongbin pei Avatar asked Sep 20 '26 15:09

hongbin pei


1 Answers

If you have not specified a folder, it will look in current folder. But you can work use wildcards. Example:

if exist *.png echo There are images here

will output the text if in the current folder there are any files with the extension .png

or you can specify a full path, for example

if exist d:\temp\*.png echo There are images there
like image 180
Jogy Avatar answered Sep 23 '26 14:09

Jogy