1.

Solve : Re: How would I create a batch file like this??

Answer»

OK, so by my understanding, you want a batch file that asks for input, and creates a directory based on that input? Let me know how this .bat file works for you:

Code: [Select]@ECHO OFF
cls
SET /P directory="Enter directory name>"
mkdir %directory%
IF NOT ERRORLEVEL 0 GOTO Error
ECHO Directory created with the name %directory%.
GOTO End

:Error
cls
ECHO The directory could not be created. Check to make SURE it does not already exist.

:EndOh, OK. I see. I APOLOGIZE for not getting it. Try this, it's similar but appends the DATE:

Code: [Select]@ECHO OFF
cls
SET /P directory="Enter directory name>"
mkdir %date:~4,2%-%date:~7,2%-%date:~12,2%_%directory%
IF NOT ERRORLEVEL 0 GOTO Error
ECHO Directory created with the name %date:~4,2%-%date:~7,2%-%date:~12,2%_%directory%.
GOTO End

:Error
cls
ECHO The directory could not be created. Check to make sure it does not already exist.

:EndOf course not, how silly of me. This code I tested just now, and it works. The only difference is that I surrounded the mkdir section in quotes. 8-)

Code: [Select]@ECHO OFF
cls
SET /P directory="Enter directory name>"
mkdir "%date:~4,2%-%date:~7,2%-%date:~12,2%_%directory%"
IF NOT ERRORLEVEL 0 GOTO Error
ECHO Directory created with the name %date:~4,2%-%date:~7,2%-%date:~12,2%_%directory%.
GOTO End

:Error
cls
ECHO The directory could not be created. Check to make sure it does not already exist.

:End*Slaps head*

Dam I should have figured that out myself so simple. Thanks again. You're welcome.Alas another bug.

When I create two folders with the same name it doesnt come up with the error message. It say it created a folder eventhough it didnt.Alright:

Code: [Select]@ECHO OFF
cls
SET /P directory="Enter directory name>"
IF EXIST "%date:~4,2%-%date:~7,2%-%date:~12,2%_%directory%" GOTO Error
mkdir "%date:~4,2%-%date:~7,2%-%date:~12,2%_%directory%"
ECHO Directory created with the name %date:~4,2%-%date:~7,2%-%date:~12,2%_%directory%.
GOTO End

:Error
cls
ECHO The directory could not be created. Check to make sure it does not already exist.

:End



Discussion

No Comment Found