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

  1.     An example batch file, RENDIR.BAT, that can be used to rename directories:
  2. @ECHO OFF
  3. REM Usage: RENDIR [d1:]pathname1 [d2:]pathname2
  4. REM This batch file will lose zero length files in the renamed directory!
  5. REM first, see if %1 is present, and is a directory, 
  6. REM and not a root directory or disk name
  7. IF zip%1==zip GOTO missdir
  8. IF EXIST %1 GOTO notdir
  9. IF NOT EXIST %1\..\NUL GOTO notdir
  10. IF NOT EXIST %1\.\NUL GOTO notdir
  11. REM second, see if %2 is present, and not a file, or disk name or
  12. REM existing directory, or a root directory
  13. IF zip%2==zip GOTO missdir
  14. IF EXIST %2 GOTO unable
  15. IF EXIST %2.\NUL GOTO unable
  16. REM third, be sure . is not %1 or a subdirectory of it
  17. REM > %1\rendir$$.tst
  18. FOR %%x IN (. .. ..\.. ..\..\.. ..\..\..\.. ..\..\..\..\.. ..\..\..\..\..\..) DO IF EXIST %%x\rendir$$.tst GOTO isdot
  19. DEL %1\rendir$$.tst
  20. REM fourth, be sure %2 can exist
  21. CTTY NUL
  22. MKDIR %2 
  23. IF NOT EXIST %2.\NUL GOTO twocant
  24. REM everything looks OK, so do it
  25. IF NOT EXIST %1\*.* GOTO isempty
  26. COPY %1\*.* %2 
  27. FOR %%a in (%1\*.*) DO DEL %%a 
  28. :isempty
  29. RMDIR %1
  30. CTTY CON
  31. IF EXIST %1\NUL ECHO Warning: Subdirectories in %1 not moved to %2
  32. GOTO eexxiitt
  33. :twocant
  34. CTTY CON
  35. :unable
  36. ECHO Unable to create directory
  37. GOTO eexxiitt
  38. :isdot
  39. IF EXIST %1\rendir$$.tst DEL %1\rendir$$.tst
  40. IF EXIST %1rendir$$.tst DEL %1rendir$$.tst
  41. :notdir
  42. ECHO Invalid path, not directory,
  43. ECHO or directory not empty
  44. GOTO eexxiitt
  45. :missdir
  46. ECHO Invalid number of parameters
  47. :eexxiitt
  48. EXIT
  49.