Checking if a folder exists using a .bat file
Checking if a folder exists using a .bat file
Checking if a folder exists using a .bat file
Re: Checking if a folder exists using a .bat file
For a file:
```
if exist yourfilename (
echo Yes
) else (
echo No
)
```
Replace **yourfilename** with the name of your file.
For a directory:
```
if exist yourfoldername\ (
echo Yes
) else (
echo No
)
```
Replace **yourfoldername** with the name of your folder.
A trailing backslash (`\`) seems to be enough to distinguish between directories and ordinary files.
[official documentation for `if`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if)
```
if exist yourfilename (
echo Yes
) else (
echo No
)
```
Replace **yourfilename** with the name of your file.
For a directory:
```
if exist yourfoldername\ (
echo Yes
) else (
echo No
)
```
Replace **yourfoldername** with the name of your folder.
A trailing backslash (`\`) seems to be enough to distinguish between directories and ordinary files.
[official documentation for `if`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if)