home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 164.lha / ARexx / Example_ARexx / du.rexx < prev    next >
OS/2 REXX Batch file  |  1988-04-28  |  912b  |  45 lines

  1. /* du.rexx -- list disk usage within a directory - by Larry Phillips */
  2. arg root
  3. if right(root,1) ~= ':' then
  4.   root = root || '/'
  5. if root = '/' then root = ''
  6.  
  7. files = 0
  8. bytes = 0
  9. blocks = 0
  10.  
  11. say
  12. temp = dolist(root)
  13. if root = '' then
  14.   say 'Current directory -' temp
  15. else
  16.   say root temp
  17. say
  18. say 'Totals:' bytes 'bytes,' blocks 'blocks, ',
  19.      files 'files.'
  20. exit 0
  21.  
  22. dolist: procedure expose bytes blocks files
  23. parse arg x
  24. dirbytes = 0
  25. contents = showdir(x);
  26. do i = 1 to words(contents)
  27.   temp = x || word(contents,i)
  28.   type = statef(temp)
  29.   if word(type,1) = 'FILE' then
  30.     do
  31.       files = files + 1
  32.       bytes = bytes + word(type,2)
  33.       blocks = blocks + word(type,3) + 1
  34.       dirbytes = dirbytes + word(type,2)
  35.     end
  36.   if word(type,1) ='DIR' then do
  37.     temp2 = dolist(temp || '/')
  38.     if temp2 > 0 then do
  39.       call writech(stdout,temp || ' -  ')
  40.       say temp2
  41.     end
  42.   end
  43. end
  44. return dirbytes
  45.