home *** CD-ROM | disk | FTP | other *** search
- @ECHO OFF
- REM
- REM mkdir - make a directory(-tree) V1.00
- REM
- REM usage: makedir dirname
- REM
- REM parameter: %dirname% = name and path of the directory to create
- REM
- REM output: Errorlevel:
- REM 0 - okay, directory created
- REM 1 - usage shown
- REM 2 - error, directory exists already
- REM 3 - error creating the directory
- REM
- REM Author: Bernd Schemmer
- REM Baeckerweg 48
- REM 60316 Frankfurt am Main
- REM Germany
- REM
- REM Note: MAKEDIR is Freeware.
- REM
- REM Last Update: 08.10.1993 /bs
- REM
-
- SETLOCAL
- ECHO. MAKEDIR - written by Bernd Schemmer 08.10.93
- ECHO.
-
- IF "%1%" == "" GOTO ShowUsage
- IF "%@upper[%1%]" == "/?" GOTO ShowUsage
- IF "%@upper[%1%]" == "/h" GOTO ShowUsage
-
- SET d=%@upper[%1]
- IF "%d%" == "" GOTO ShowUsage
- IF "%d%" == "/?" GOTO ShowUsage
- IF "%d%" == "/H" GOTO ShowUsage
-
- IF "%@name[%d%CON]" NE "CON" SET d=%d%\
-
- IF EXIST %d%CON GOTO DirAlreadyExists
-
- ECHO. Creating the directory %d% ...
-
- SET l=0
-
- :MDLoop0
- IF EXIST %d%CON (cdd %d% ^ GOTO MakeTheDir )
- SET l=%@eval[%l%+1]
-
- SET t=%@substr[%d%,0,%@eval[%@len[%d]-1]]
- SET d=%@path[%t%]
- SET d%l%=%@name[%t%].%@ext[%t%]
- GOTO MDLoop0
-
- :MakeTheDir
- pushd
-
- :MDLoop2
- ECHO. Creating the directory %_cwds%%[d%l%] ...
- IF "%l%" EQ "0" GOTO MDLoopEnd
- MD %[d%l%]
- IF "%_?" NE "0" GOTO ErrEnd
- CD %[d%l%]
- IF "%_?" NE "0" GOTO ErrEnd
- SET l=%@eval[%l%-1]
- GOTO MDLoop2
-
- :MDLoopEnd
- popd
-
- :OKEnd
- ECHO. ... directory %1 created.
- ENDLOCAL
- QUIT 0
-
- :ShowUsage
- ECHO. Usage: MAKEDIR dirname
- QUIT 1
-
- :DirAlreadyExists
- ECHO. Directory %1 already exists.
- ENDLOCAL
- QUIT 2
-
- :ErrEnd
- ECHO. Error creating the directory %1!
- ENDLOCAL
- QUIT 3
-