home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / stree.zip / stree.cmd
OS/2 REXX Batch file  |  1999-05-18  |  2KB  |  79 lines

  1. /**************************************\
  2. *                                      *
  3. *  Recursive Tree Size Report Utility  *
  4. *  ----------------------------------  *
  5. *  Written by: Matthew C. Davis        *
  6. *  Written on: May 18th, 1999          *
  7. *  Contact at: davis_mc@lrc.edu        *
  8. *                                      *
  9. *-Description--------------------------*
  10. *                                      *
  11. * Reports a list of directories and    *
  12. * subdirectories to the screen as well *
  13. * as the size of the directory's       *
  14. * contents.  It tallies tree totals,   *
  15. * and tags directories that exceed the *
  16. * specified threshold in bytes.        *
  17. *                                      *
  18. *--------------------------------------*
  19. *       HTTP://KO.THETAXI.COM          *
  20. \**************************************/
  21.  
  22. Signal on Halt
  23.  
  24. Parse arg directory,tagsize
  25.  
  26. directory=strip(directory)
  27. If directory='' then directory=directory()
  28. If strip(tagsize)='' | Datatype(tagsize,'N')=0 Then tagsize=10000000
  29.  
  30. If Right(directory,1)='\' Then Directory=Left(directory,length(directory)-1)
  31.  
  32. Say 'Generating recursive consumption report for:'
  33. Say '  'directory
  34. Say '--------------------------------------------'
  35. Tmp=rlist(directory,0,tagsize)
  36. Say '--------------------------------------------'
  37. Say 'GRAND TOTAL: 'Tmp' bytes'
  38.  
  39. Exit
  40.  
  41. /****************/
  42. rlist: Procedure
  43.    Parse Arg this,depth,thresh
  44.  
  45.    depth=depth+1
  46.    Call charout ,'  '
  47.    Do i=1 to depth-1
  48.       Call charout ,'│ '
  49.    End
  50.                                         
  51.    hit.0=0
  52.    bytes=0
  53.    Call SysFileTree this'\*','hit.','TF'
  54.    Do i=1 to hit.0
  55.       bytes=bytes+Word(hit.i,2)
  56.    End
  57.    Say this' - 'bytes' bytes'
  58.  
  59.    hit.0=0
  60.    totalbytes=bytes
  61.    Call sysFileTree this'\*','hit.','OD'
  62.    Do i=1 to hit.0
  63.       totalbytes=totalbytes+rlist(hit.i,depth,thresh)
  64.    End
  65.    
  66.    If hit.0>0 Then Do
  67.       If totalbytes>thresh Then Call charout ,'>>'
  68.       Else Call charout ,'  '
  69.  
  70.       Do i=1 to depth-1
  71.          Call charout ,'│ '
  72.       End
  73.       Say 'TOTAL: 'totalbytes' ('this')'
  74.    End
  75.  
  76. Return totalbytes
  77. /*****************************/
  78. Halt:
  79. Exit