home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / kt_98125.zip / KILLTREE.CMD
OS/2 REXX Batch file  |  1998-05-05  |  2KB  |  73 lines

  1. /*
  2.  * REXXIT VERSION: 96.299a
  3.  * PROCESSED AT  : Tue May 05 1998 08:45:54PM
  4.  * SOURCE        : E:\DB\PROJECTS\OS2\KILLTREE\KILLTREE.X
  5.  * DESTINATION   : .\OUT\KILLTREE.CMD
  6.  */
  7.  
  8. /* @ START FILE: E:\DB\PROJECTS\OS2\KILLTREE\KILLTREE.X (Tue May 05 1998 08:45:50PM) */
  9. ColorError     = '';
  10. ColorHighlight = '';
  11. ColorNormal    = '';
  12. ColorReset     = '';
  13. AddRc = RxFuncAdd('SysFileTree', 'RexxUtil', 'SysFileTree');
  14. call charout ,ColorHighlight;
  15. say "[]--------------------------------------------------------------[]";
  16. say "| KILLTREE.CMD, Version 98.125 (C)opyright by Dennis Bareis 1993 |";
  17. say "|               http://www.ozemail.com.au/~dbareis (db0@anz.com) |";
  18. say "[]--------------------------------------------------------------[]";
  19. say "";
  20. call charout ,ColorReset;
  21. Arguments = arg(1);
  22. parse var Arguments TreeBase SubCommand;
  23. parse upper var SubCommand SubCommand;
  24. if  TreeBase = "" then
  25. call SyntaxError 'Expected the name of a directory to delete.';
  26. Directory.0 = 0;
  27. call SysFileTree TreeBase, 'Directory', 'DS'
  28. if Directory.0 = 0 then
  29. call SyntaxError 'The directory "' || TreeBase || '" does not exist.';
  30. RoutineRc = 0;
  31. call SysFileTree TreeBase || '\*.*', 'Directory', 'DS'
  32. do i=1 to Directory.0
  33. DoDir = (Directory.0 - i) + 1;
  34. parse var Directory.DoDir DirDate DirTime DirSize DirAttr DirName;
  35. DeleteRc = Delete1Dir(strip(DirName), SubCommand);
  36. if  DeleteRc <> 0 then
  37. RoutineRc = DeleteRc;
  38. end;
  39. DeleteRc = Delete1Dir(TreeBase, SubCommand);
  40. if DeleteRc <> 0 then
  41. RoutineRc = DeleteRc;
  42. exit(RoutineRc);
  43. Delete1Dir:
  44. ThisDir        = arg(1);
  45. SpecialCommand = arg(2);
  46. say ColorNormal || 'Deleting: ' || ThisDir;
  47. address cmd '@attrib -r -h -s ' || ThisDir || '\*.* >nul';
  48. call charout ,ColorError;
  49. if  stream(ThisDir || '\*.*', 'c', 'query exists') <> '' then
  50. do
  51. address cmd '@del "' || ThisDir || '" /n >nul';
  52. end;
  53. address cmd '@rd "' || ThisDir || '" >nul';
  54. call charout ,ColorReset;
  55. return(Rc);
  56. SyntaxError:
  57. CallersLine = SIGL;
  58. call charout ,ColorError;
  59. say "This program deletes a directory tree.  It will delete files which"
  60. say "are protected (read-only etc).";
  61. say "";
  62. say "CORRECT SYNTAX";
  63. say "~~~~~~~~~~~~~~";
  64. say "   KILLTREE[.CMD]  DirName";
  65. say "";
  66. say "REASON";
  67. say "~~~~~";
  68. say "   " || arg(1) || ColorReset || "";
  69. exit(CallersLine);
  70. Die:
  71. exit(sigl);
  72. /* @ END   FILE: E:\DB\PROJECTS\OS2\KILLTREE\KILLTREE.X (processed 109 lines) */
  73.