home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / doshelp / helpsb.zoo / help / rd / rdstar.hlp < prev    next >
Encoding:
Text File  |  1989-01-01  |  2.6 KB  |  76 lines

  1.   A sample BATCH file to delete a subdirectory and all its subdirectories.
  2. @ECHO OFF
  3. REM
  4. REM RDSTAR, a BATCH file to do a recursive operation on a directory subtree
  5. REM %1=the disk name, a CAPITAL LETTER and colon
  6. REM %2=a complete pathname starting with \, in ALL CAPITAL LETTERS
  7. REM
  8. REM first, see if a valid pathname in %1
  9. IF zip%2==zip GOTO missorno
  10. IF NOT %2==\ GOTO notroot1
  11. IF NOT EXIST %1\.\NUL GOTO missorno
  12. GOTO rootok
  13. :notroot1
  14. IF NOT EXIST %1%2\.\NUL GOTO missorno
  15. :rootok
  16. ECHO     All subdirectories of %1%2 will be destroyed!
  17. ECHO:
  18. ECHO Do you really want to do this? (Press ENTER to continue, Ctrl-C to quit)
  19. PAUSE > NUL
  20. REM second, get list of directories to be operated on
  21. REM In case clusters messed up, give CHKDSK an input answer of "n"
  22. ECHO n > %1\star$tmp.$1$
  23. CHKDSK %1 /V > %1\star$tmp.$2$ < %1\star$tmp.$1$
  24. IF NOT %2==\ GOTO notroot2
  25. FIND "Directory %1" %1\star$tmp.$2$ > %1\star$tmp.$1$
  26. GOTO third
  27. :notroot2
  28. FIND "Directory %1%2" %1\star$tmp.$2$ > %1\star$tmp.$1$
  29. :third
  30. REM third, use DEBUG to create files controlling EDLINs
  31. ECHO n star$del.$0$> %1\star$tmp.$3$
  32. ECHO e 0100 "1,#RDirectoryzDELdaEda">> %1\star$tmp.$3$
  33. ECHO e 010D 1A>> %1\star$tmp.$3$
  34. ECHO e 0111 0D 0A>> %1\star$tmp.$3$
  35. ECHO e 0114 0D 0A>> %1\star$tmp.$3$
  36. ECHO rcx>> %1\star$tmp.$3$
  37. ECHO 0016>> %1\star$tmp.$3$
  38. ECHO w>> %1\star$tmp.$3$
  39. ECHO n star$rd$.$0$>> %1\star$tmp.$3$
  40. ECHO e 010E "RD ">> %1\star$tmp.$3$
  41. ECHO w>> %1\star$tmp.$3$
  42. ECHO n star$y$$.$0$>> %1\star$tmp.$3$
  43. ECHO e 010E "Y  ">> %1\star$tmp.$3$
  44. ECHO w>> %1\star$tmp.$3$
  45. ECHO q>> %1\star$tmp.$3$
  46. DEBUG < %1\star$tmp.$3$ > NUL
  47. ECHO 1,2D>star$hdr.$0$
  48. IF NOT %2==\ GOTO notroot3
  49. ECHO 1,3D>star$hdr.$0$
  50. :notroot3
  51. ECHO E>>star$hdr.$0$
  52. REM fourth, sort the list to operate from bottom to top of tree structure
  53. EDLIN %1\star$tmp.$1$ < star$hdr.$0$ > NUL
  54. DEL %1\star$tmp.bak 
  55. SORT /R < %1\star$tmp.$1$ > star$del.bat 
  56. REM fifth, use EDLIN to produce batch files to DEL and RM each subdirectory
  57. EDLIN star$del.bat < star$del.$0$ > NUL
  58. REN star$del.bak star$rd$.bat
  59. EDLIN star$rd$.bat < star$rd$.$0$ > NUL
  60. REN star$rd$.bak star$y$$.bat
  61. EDLIN star$y$$.bat < star$y$$.$0$ > NUL
  62. REM sixth, DEL each subdirectory, with a "y" response
  63. COMMAND /C star$del < star$y$$.bat > NUL
  64. IF %2==\ DEL %1\*.* < star$y$$.bat > NUL
  65. REM seventh, RD each subdirectory 
  66. COMMAND /C star$rd$ > NUL
  67. REM eighth, clean up all temporary files
  68. IF EXIST star$???.$?$ DEL star$???.$?$
  69. IF EXIST star$???.ba? DEL star$???.ba?
  70. IF EXIST %1\star$tmp.$?$ DEL %1\star$tmp.$?$
  71. GOTO eexxiitt
  72. :missorno
  73. ECHO Missing or invalid pathname
  74. :EEXXIITT
  75. EXIT
  76.