home *** CD-ROM | disk | FTP | other *** search
/ TopWare Tools / TOOLS.iso / tools / top1630 / makedir.btm next >
Encoding:
Text File  |  1993-10-09  |  1.7 KB  |  89 lines

  1. @ECHO OFF
  2. REM
  3. REM mkdir - make a directory(-tree) V1.00
  4. REM
  5. REM usage: makedir dirname
  6. REM
  7. REM parameter:  %dirname% = name and path of the directory to create
  8. REM    
  9. REM output: Errorlevel:
  10. REM        0 - okay, directory created
  11. REM             1 - usage shown
  12. REM             2 - error, directory exists already
  13. REM        3 - error creating the directory
  14. REM
  15. REM Author: Bernd Schemmer
  16. REM         Baeckerweg 48
  17. REM         60316 Frankfurt am Main
  18. REM         Germany
  19. REM 
  20. REM Note:   MAKEDIR is Freeware.
  21. REM
  22. REM Last Update: 08.10.1993 /bs
  23. REM
  24.  
  25. SETLOCAL
  26. ECHO. MAKEDIR - written by Bernd Schemmer 08.10.93
  27. ECHO.
  28.  
  29. IF "%1%" == "" GOTO ShowUsage
  30. IF "%@upper[%1%]" == "/?" GOTO ShowUsage
  31. IF "%@upper[%1%]" == "/h" GOTO ShowUsage
  32.  
  33. SET d=%@upper[%1]
  34. IF "%d%" == "" GOTO ShowUsage
  35. IF "%d%" == "/?" GOTO ShowUsage
  36. IF "%d%" == "/H" GOTO ShowUsage
  37.  
  38. IF "%@name[%d%CON]" NE "CON" SET d=%d%\
  39.  
  40. IF EXIST %d%CON GOTO DirAlreadyExists
  41.  
  42. ECHO. Creating the directory %d% ...
  43.  
  44. SET l=0
  45.  
  46. :MDLoop0
  47. IF EXIST %d%CON (cdd %d% ^ GOTO MakeTheDir )
  48. SET l=%@eval[%l%+1]
  49.  
  50. SET t=%@substr[%d%,0,%@eval[%@len[%d]-1]]
  51. SET d=%@path[%t%]
  52. SET d%l%=%@name[%t%].%@ext[%t%]
  53. GOTO MDLoop0
  54.  
  55. :MakeTheDir
  56. pushd
  57.  
  58. :MDLoop2
  59. ECHO.     Creating the directory %_cwds%%[d%l%] ...
  60. IF "%l%" EQ "0" GOTO MDLoopEnd
  61. MD %[d%l%]
  62. IF "%_?" NE "0" GOTO ErrEnd
  63. CD %[d%l%]
  64. IF "%_?" NE "0" GOTO ErrEnd
  65. SET l=%@eval[%l%-1]
  66. GOTO MDLoop2
  67.  
  68. :MDLoopEnd
  69. popd
  70.  
  71. :OKEnd
  72. ECHO. ... directory %1 created.
  73. ENDLOCAL
  74. QUIT 0
  75.  
  76. :ShowUsage
  77. ECHO. Usage: MAKEDIR dirname
  78. QUIT 1
  79.  
  80. :DirAlreadyExists
  81. ECHO. Directory %1 already exists.
  82. ENDLOCAL
  83. QUIT 2
  84.  
  85. :ErrEnd
  86. ECHO. Error creating the directory %1!
  87. ENDLOCAL
  88. QUIT 3
  89.