home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / DAB2.ZIP / DAB.CMD
OS/2 REXX Batch file  |  1992-11-11  |  3KB  |  101 lines

  1. /*  delete all but for OS/2  */
  2. /*  Jeff Elkins 1992 */
  3.  
  4.  
  5. CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  6. CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
  7.  
  8. ARG ext1 ext2 ext3 ext4 ext5 ext6 ext7 ext8 ext9 ext10
  9.  
  10. IF STRIP(ext1,'B') = '' THEN
  11.     DO 
  12.              SAY 'You must enter a argument holding 1 to 10 file templates'
  13.              SAY
  14.              SAY 'I.E. *.exe *.cmd *.com passed as a template string'
  15.              SAY 'would delete all files which don''t match the'
  16.              SAY 'supplied file extensions'
  17.              EXIT 3
  18.     END
  19.  
  20. t.1  = ext1
  21. t.2  = ext2
  22. t.3  = ext3
  23. t.4  = ext4
  24. t.5  = ext5
  25. t.6  = ext6
  26. t.7  = ext7
  27. t.8  = ext8
  28. t.9  = ext9
  29. t.10 = ext10
  30.  
  31.  
  32. file_error.0   = 'File deleted successfully. '
  33. file_error.2   = 'Error.  File not found. '
  34. file_error.3   = 'Error.  Path not found. '
  35. file_error.5   = 'Error.  Access denied. '
  36. file_error.26  = 'Error.  Not DOS disk. '
  37. file_error.32  = 'Error.  Sharing violation. '
  38. file_error.36  = 'Error.  Sharing buffer exceeded. '
  39. file_error.87  = 'Error.  Invalid parameter. '
  40. file_error.206 = 'Error.  Filename exceeds range error. '
  41.  
  42.  
  43. /***********************************************************/
  44. /* hide the files to be kept                               */
  45. /***********************************************************/
  46.  
  47. DO x = 1 TO 10
  48. ext = t.x
  49. IF STRIP(ext,'B') <> '' THEN
  50.    rc=SysFileTree(ext, dir_list, 'F', '*****','**+**')
  51. END
  52.  
  53.  
  54. /**************************************************************/
  55. /* pull the files to be deleted into a stem, then delete them */
  56. /**************************************************************/
  57.  
  58.  
  59. rc=SysFileTree('*.*', del_file, 'FO', '**-**','*****')
  60.  
  61. df = del_file.0
  62. fn = 0
  63.  
  64. DO x = 1 TO df
  65.         SAY del_file.x
  66.         fn = fn + 1
  67.         IF fn >= 23 THEN
  68.          DO
  69.           say 'press return'
  70.           pull resp
  71.           fn = 0
  72.          END
  73.        END
  74.  
  75. SAY
  76. SAY 'delete these files (Y/N) ?'
  77. PULL resp
  78.  
  79. IF resp = "Y" then
  80. DO x = 1 TO df
  81.         rc = SysFileDelete(del_file.x)
  82.         SAY del_file.x '........' file_error.RC
  83. END
  84.  
  85.  
  86. /**************************************************************/
  87. /* unhide the hidden files                                    */
  88. /**************************************************************/
  89.  
  90.  
  91.  
  92. DO x = 1 TO 10
  93. ext = t.x
  94. IF STRIP(ext,'B') <> '' THEN
  95.    rc=SysFileTree(ext, dir_list, 'F', '**+**','**-**')
  96. END
  97.  
  98. say
  99. IF resp = "Y" then say df 'files deleted'
  100. exit
  101.