How to make prompted directory

Hi, I am prompting user for a directory to be created in my batch file using
set /p dir=Enter the folder to create:
but when I go to mkdir, it is not makeing the right directory.
Sometimes it makes 2 or more directorys from the command.
How can I fix this?

sher19Asked:
Who is Participating?
 
sirbountyConnect With a Mentor Commented:
I would probably advise against using dir as a variable as well...since it's an internal command.
I usually use something like

set strDir /p = Enter the folder to create
md "%strDir%
0
 
sirbountyCommented:
Hello sher19,

Use the quotes around your directory...odds are the user is entering a directory with spaces in the name...
So, in your code, isntead of

mkdir %dir%

use

mkdir "%dir%"

Regards,

sirbounty
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.