home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / cleanup2.lha / CleanUp.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1992-12-24  |  2.2 KB  |  71 lines

  1. /*
  2.  
  3.                       $VER: CleanUp 2.00 (23-DEC-92)
  4.  
  5.               © 1992 by Robert Hofmann 2:2400/24@fidonet.org
  6.  
  7.  
  8. */
  9.  
  10. LogFile         = 'logs:TD.log'
  11.  
  12. Directory.1     = 'BAK:'
  13. RemainingDays.1 = 2
  14.  
  15. Directory.2     = 'Outbound:'
  16. RemainingDays.2 = 30
  17.  
  18. Directory.3     = 'Inbound:'
  19. RemainingDays.3 = 90
  20.  
  21. Directory.4     = 'T:'
  22. RemainingDays.4 = 1
  23.  
  24. Directory.5     = 'DH2:BAD'
  25. RemainingDays.5 = 7
  26.  
  27. /* and so on... */
  28.  
  29.  
  30. arg mode
  31.  
  32. ver = 'v2.0'
  33. if find(mode, 'QUIET') = 0 then do; say; say ' *** CleanUp' ver '***'; say '     ~~~~~~~~~~~~'; say ' © 1992 by Robert Hofmann 2:2400/24@fidonet.org'; say
  34.  say ' (Actual date:' translate(date(),'-',' ') time()')'; say; say; end
  35.  
  36. if ~show(l, "rexxsupport.library") then
  37.  if ~addlib("rexxsupport.library", 0, -30, 0) then do
  38.   say "*** Error: Couldn't access rexxsupport.library!"; exit; end
  39.  
  40. Now = date('I'); count = 0; delcount = 0; nr = 0
  41.  
  42. do n=1 while Directory.n ~= 'DIRECTORY.'n
  43.  
  44.  if right(Directory.n,1) ~= ':' & right(Directory.n,1) ~= '/' then Directory.n = Directory.n'/'
  45.  files = showdir(Directory.n, 'F')
  46.  
  47.  do until files = ''; parse var files check files
  48.   file  = upper(Directory.n || check); Days  = word(statef(file),5)
  49.   datum = translate(date('N',days,'I'),'-',' '); count = count + 1
  50.   if now-days > RemainingDays.n then do; length = word(statef(file),2) 'bytes.'
  51.    if find(mode, 'QUIET') = 0 then do; say ' * File <'file'>,' length
  52.     say '    is older than' RemainingDays.n 'days ('Datum'), deleting...'; say; end
  53.    delcount=delcount+1; nr=nr+1; line.nr = time() upper(' "'file'"') Datum 'deleted...'
  54.    if find(mode, 'DELETE') ~= 0 then call delete(file)
  55.   end
  56.  end
  57. end
  58.  
  59. if logfile ~= '' & find(mode, 'DELETE') ~= 0 then do
  60.  if   ~exists(logfile) then call open('log',logfile,'W')
  61.  else                       call open('log',logfile,'A')
  62.  datum = date(); if left(datum,1) = '0' then datum = ' 'right(delstr(translate(datum, '-', ' '), 8, 2),8)
  63.                  else datum = delstr(translate(datum, '-', ' '), 8, 2)
  64.  do n=1 to nr; logstr = 'C' datum line.n; call WriteLn('log',logstr); end
  65.  call WriteLn('log', 'C' datum time() ' *** Checked' count 'files,' delcount 'deleted. ***')
  66.  call close('log')
  67. end
  68.  
  69. if find(mode, 'QUIET') = 0 then do; say; say ' ==>> Checked' count 'files,' delcount 'deleted. <<=='; say; end
  70.  
  71.