home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / perf31.zip / perf_30 / elimdir.cmd < prev    next >
OS/2 REXX Batch file  |  1994-11-06  |  3KB  |  103 lines

  1. /* ELIMDIR - Eliminates Directories, Sub-Directories and all the files in those directories*/
  2. /*Copyright (c) 1994 CLEAR & SIMPLE, INC.*/
  3. ECHO OFF
  4.  
  5. Signal on Error
  6. rc=RXQUEUE("Create", 'elimdirQ')
  7. rc=RXQUEUE("Set", 'elimdirQ')
  8. do queued()
  9.    pull
  10. end 
  11.  
  12. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  13. call SysLoadFuncs
  14.  
  15. red        ='A'
  16. green      ='A'
  17. yellow     ='A'
  18. blue       ='A'
  19. white      ='A'
  20. black      ='A'
  21.  
  22. arg deaddir Confirm .
  23. if deaddir='' then do
  24. echo on
  25. 'prompt $p$E[0;'34';'47';'5';'5'm]'
  26. echo off
  27. 'cls'
  28.  
  29. say blue;say 'ELIMDIR - Eliminates Directories (and Files and Sub-Directories)'
  30. say black;say '  Performance PLUS V3 PLUS CopyRight (c) 1994, Clear & Simple, Inc.'
  31. say blue;say;say 'ElimDIR was written to be executed from the command line.'
  32. say;say '   e.g.  ElimDir  D:\OLDDATA '
  33. say;say 'You have either started it from the ICON or without parameters.'
  34. say; say red; say 'U S E  ElimDir   W I T H   G R E A T   C A U T I O N'
  35. SAY;SAY GREEN;say 'It will easily delete entire directories INCLUDING ALL FILES!'
  36. SAY;SAY RED;say 'C A U T I O N ! ! !  -  READ THE PLUSread.me BEFORE USING'
  37. SAY; SAY BLUE; say 'Press any key to end'; key=sysgetkey()
  38. EXIT
  39. end 
  40.  
  41. deaddir=strip(deaddir,'T','\')
  42. say 'Deleting Directory:' Deaddir
  43. say '    and all files and subdirectories within that directory!'
  44.  
  45. if translate(Confirm) \= 'Y' then do
  46.    say red; say; say '   *****  C A U T I O N  *****'
  47.         say '  This program will delete ALL FILES and ALL Directories! '
  48.         say '  Are you sure you want to proceed?'; say;
  49.         say blue; say 'Press "Y" and Enter to continue';SAY WHITE; pull okay
  50.         if okay \= 'Y' then do
  51.                  SAY WHITE; say 'NO DELETION!';  exit
  52.                  end  /* Y Do */
  53.      end  /* Confirm Do */
  54.  
  55. IF filespec('drive',deaddir)='' then if right(directory(),1)='\'then deaddir=directory()||deaddir
  56. else deaddir=directory()'\'deaddir
  57.  
  58. parse var deaddir drive ':' rest
  59. if left(rest,1) ='\' | rest='' then do;
  60.         parse var rest '\' rest1; 
  61.         if rest1='' then do; 
  62.               say 'Is the ROOT DIRECTORY of DRIVE 'drive '?';
  63.               say 'ARE YOU SURE YOU WANT TO DELETE THE ENTIRE DRIVE?'
  64.               say "To continue you must respond 'YES'";
  65.               pull ans; if ans \= 'YES' then do
  66.                       say white; say 'NO DELETION!'; exit
  67.                       end  /* YES Do */
  68.               end /* rest1 do*/
  69.         end
  70.  
  71.  
  72. rc=SysFileTree(deaddir'\*.*',dirs,'BS', '*****', '-----')
  73. do i=1 to dirs.0
  74. parse var dirs.i day time size att file
  75.  
  76. push att file; 
  77. end 
  78.  
  79. do Queued()
  80. pull att file;file=strip(file,'L');filewithblanks='"'file'"';
  81. if pos('D', att) = 2 then 'RD' filewithblanks
  82. else do;  'del' filewithblanks '/N'; end
  83. end 
  84.  
  85. if ans\='YES' then do
  86. 'RD' DEADDIR
  87. end
  88. RC=RXQUEUE('Delete', 'elimdirQ')
  89. Say; say '  Deletion of ' deaddir 'Completed!'
  90. exit
  91.  
  92. error:
  93. say 'Errors have occured'
  94. say 'Probably a file in the directory structure' deadir
  95. say ' is being used by another process or the directory'
  96. say ' is active in another active command prompt window.'
  97. say 'deaddir is =' deaddir
  98. do queued()
  99.    pull
  100. end /* do */
  101. rc=RXQUEUE('Delete', 'elimdirQ')
  102. exit
  103.