home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / SIZE!.ZIP / SIZE!.CMD
OS/2 REXX Batch file  |  1993-02-21  |  3KB  |  209 lines

  1. /*----------------------------------------------------------------+
  2. |                                                                 |
  3. | Size!.CMD, (C)opyright 1993 by Dave McCutcheon (76174,2013)     |
  4. |                                                                 |
  5. | Based on:                                                       |
  6. | RD!.CMD, (C)opyright 1992 by Arthur Tyde                        |
  7. |                                                                 |
  8. | Shareware- if you dig this and can spare something in trade     |
  9. | send it to 11 S. Knoll #16, Mill Valley, CA 94941.              |
  10. |                                                                 |
  11. | Size! will calculate the size of entire tree structures of any  |
  12. | FAT or HPFS subdirectory.                                       |
  13. |                                                                 |
  14. +----------------------------------------------------------------*/
  15. parse upper arg target_dir
  16.  
  17. say
  18. if queued()>0 then call drainq
  19. if target_dir\='' then do
  20.    target_dir='"'target_dir'"'
  21.    call Sum_Up
  22. end
  23. else do
  24.    say 'Size! - Calculate the size of a directory, and all subdirectories.'
  25.    say '        Supports FAT and HPFS long filenames.'
  26.    say '        (C)opyright 1993, David W. McCutcheon (76174,2013)'
  27.    say
  28.    say '    -> SYNTAX: Size! c:\OS2'
  29.    say '               Size! Oracle6'
  30.    say '               Size! OS!2 2.0 Desktop'
  31.    say "               Size! Special^Character's.DIR"
  32. end
  33. bailout:
  34. say
  35. say '....' time() '- End Size!'
  36. exit
  37.  
  38. Sum_Up:
  39. rc = SETLOCAL()
  40. drv = substr(target_dir, 2, 2)
  41. IF  substr(drv, 2, 2) = ':'  THEN  DO
  42.     '@' drv
  43.     IF  rc <> 0  THEN  DO
  44.         say '->' time()", Target drive dosen't exist."
  45.         signal bailout
  46.     END
  47. END
  48. '@CD' target_dir '1>NUL 2>NUL'
  49. if rc\=0 then do
  50.    say '->' time()", Target directory dosen't exist."
  51.    signal bailout
  52. end
  53. say '....' time() '- Summing file sizes...'
  54. say
  55. call Sum_Structure
  56. say
  57. say FORMAT(files, 10),
  58.     'file(s)',
  59.     FORMAT(bytes, 10),
  60.     'bytes  (including Extended Attribute [EA] bytes)'
  61. rc = ENDLOCAL()
  62. return
  63.  
  64. Sum_Structure:
  65. file_list='';dir_list=''
  66. '@DIR /S /A-D /N 2>NUL | RXQUEUE' /* all files in structure */
  67. files = 0
  68. bytes = 0
  69. file.0 = queued()
  70. do i=1 to file.0
  71.    parse pull x
  72.    IF  substr(x, 1, 5) = 'Total'  THEN  Leave
  73.    IF  substr(x, 2, 9) = 'Directory'  THEN  d = substr(x, 15, 40)
  74.    IF  substr(x, 12, 7) = 'file(s)'  THEN  call Line_Out
  75.    IF  substr(x, 13, 1) = ':'  THEN  call Sum_Bytes
  76. end
  77. return
  78.  
  79. Sum_Bytes:
  80. bytes = bytes + substr( x, 31, 8 )
  81. IF  substr(x, 22, 5) <> '<DIR>'  THEN  bytes = bytes + substr( x, 19, 8 )
  82. return
  83.  
  84. Line_Out:
  85. say substr(x, 1, 36) d
  86. files = files + substr( x, 7, 4 )
  87. return
  88.  
  89. drainq:
  90. /* say 'dqs' */
  91. do queued()
  92.    parse pull .
  93. end
  94. /* say 'dqe' */
  95. return
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.