To check for the presence of a directory (or folder) you can use the IF EXIST statement. For example, to test for C:\TEMP and then change to C:\TEMP if it exists, else create the directory and change to it, use the following batch file:
C:
IF NOT EXIST C:\TEMP GOTO MAKEDIR
CD \TEMP
EXIT
:MAKEDIR
MD C:\TEMP
CD \TEMP
EXIT
It won't work if c:\temp is a file or the current directory is not on disk c:
ReplyDelete