home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
SIZE!.ZIP
/
SIZE!.CMD
Wrap
OS/2 REXX Batch file
|
1993-02-21
|
3KB
|
209 lines
/*----------------------------------------------------------------+
| |
| Size!.CMD, (C)opyright 1993 by Dave McCutcheon (76174,2013) |
| |
| Based on: |
| RD!.CMD, (C)opyright 1992 by Arthur Tyde |
| |
| Shareware- if you dig this and can spare something in trade |
| send it to 11 S. Knoll #16, Mill Valley, CA 94941. |
| |
| Size! will calculate the size of entire tree structures of any |
| FAT or HPFS subdirectory. |
| |
+----------------------------------------------------------------*/
parse upper arg target_dir
say
if queued()>0 then call drainq
if target_dir\='' then do
target_dir='"'target_dir'"'
call Sum_Up
end
else do
say 'Size! - Calculate the size of a directory, and all subdirectories.'
say ' Supports FAT and HPFS long filenames.'
say ' (C)opyright 1993, David W. McCutcheon (76174,2013)'
say
say ' -> SYNTAX: Size! c:\OS2'
say ' Size! Oracle6'
say ' Size! OS!2 2.0 Desktop'
say " Size! Special^Character's.DIR"
end
bailout:
say
say '....' time() '- End Size!'
exit
Sum_Up:
rc = SETLOCAL()
drv = substr(target_dir, 2, 2)
IF substr(drv, 2, 2) = ':' THEN DO
'@' drv
IF rc <> 0 THEN DO
say '->' time()", Target drive dosen't exist."
signal bailout
END
END
'@CD' target_dir '1>NUL 2>NUL'
if rc\=0 then do
say '->' time()", Target directory dosen't exist."
signal bailout
end
say '....' time() '- Summing file sizes...'
say
call Sum_Structure
say
say FORMAT(files, 10),
'file(s)',
FORMAT(bytes, 10),
'bytes (including Extended Attribute [EA] bytes)'
rc = ENDLOCAL()
return
Sum_Structure:
file_list='';dir_list=''
'@DIR /S /A-D /N 2>NUL | RXQUEUE' /* all files in structure */
files = 0
bytes = 0
file.0 = queued()
do i=1 to file.0
parse pull x
IF substr(x, 1, 5) = 'Total' THEN Leave
IF substr(x, 2, 9) = 'Directory' THEN d = substr(x, 15, 40)
IF substr(x, 12, 7) = 'file(s)' THEN call Line_Out
IF substr(x, 13, 1) = ':' THEN call Sum_Bytes
end
return
Sum_Bytes:
bytes = bytes + substr( x, 31, 8 )
IF substr(x, 22, 5) <> '<DIR>' THEN bytes = bytes + substr( x, 19, 8 )
return
Line_Out:
say substr(x, 1, 36) d
files = files + substr( x, 7, 4 )
return
drainq:
/* say 'dqs' */
do queued()
parse pull .
end
/* say 'dqe' */
return