How to check if a sub-path exist using batch file

231 views Asked by At

I would like to be able to get path from user like (C:\Users\mehak\Downloads\folderA\folderB)

SET /P USER_INSTALL= Installation Path : 

Now i want to check if (FolderA) exists then create a subfolder (folderB).

Does anybody have any idea how can i create a batch file to allow me to do this?

1

There are 1 answers

0
Magoo On
MD "%user_install%\folderb"  >nul 2>nul
if exist "%user_install%\folderb\." (
 echo Folderb created
) else (
 echo Folderb not created
)

Will create folderb under %user_install% whether or not either already exists.

Don't move the parentheses in the if statement - they are quite critical.