Posted By: Anonymous
I would like to be able to check if a certain folder (FolderA) exists and if so, for a message to be displayed and then the batch file to be exited.
If FolderA does not exist, I would then like to check if another folder (FolderB) exists. If FolderB does not exist, a message should be displayed and the folder should be created, and if FolderB does exist, a message should be displayed saying so.
Does anybody have any idea on the code I could simply use on notepad to create a batch file to allow me to do this?
All of this needs to be done in one
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.