/* DiskUse.cmd, Version 4.00 for OS/2 and Regina Rexx */ /* Display diskspace used by subdirectories */ /* Written by Rob van der Woude */ /* http://www.robvanderwoude.com */ /* Initialize RexxUtil */ Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs" Call sysloadfuncs /* Initialize RexxLib */ If RxFuncQuery( "RexxLibRegister" ) <> 0 Then Do If RxFuncAdd( "RexxLibRegister", "RexxLib", "RexxLibRegister" ) = 0 Then Call RexxLibRegister End /* Command line parsing */ Parse Upper Arg startdir If Pos( "?", startdir ) > 0 Then Call Syntax Select When startdir = "" Then fdir = directory( ) When startdir = "." Then fdir = directory( ) When startdir = ".." Then fdir = directory( ".\..\." ) Otherwise Do Call SysFileTree startdir, "exist.", "DO" If exist.0 <> 1 Then Do Call Syntax "Specified startdir not found: "||startdir End fdir = exist.1 End End fdir = Strip( fdir, "T", "\" ) fdlen = Length( fdir ) + 1 /* Display total file size for start directory */ Call SysFileTree fdir||"\*", "files.", "F" totalsize = 0 If files.0 > 0 Then Do j = 1 to files.0 Parse Value files.j With . . fsize . files.j files.j = Strip( files.j ) totalsize = totalsize + fsize End Say ".\="||totalsize /* Display total file size for all subdirectories */ Call SysFileTree fdir||"\*", "fdirs.", "DO" If fdirs.0 > 0 Then Do If RxFuncQuery( "ArraySort" ) = 0 Then Call ArraySort "fdirs." Do i = 1 To fdirs.0 Call SysFileTree fdirs.i||"\*", "files.", "FS" totalsize = 0 If files.0 > 0 Then Do j = 1 to files.0 Parse Value files.j With . . fsize . files.j files.j = Strip( files.j ) totalsize = totalsize + fsize End Say SubStr( fdirs.i, fdlen + 1 )||"="||totalsize End End Exit 0 Syntax: msg = Arg( 1 ) If msg <> "" Then Do Say Say msg End Say Say "DiskUse, Version 4.00 for OS/2 and Regina Rexx" Say "Display diskspace used by current directory and subdirectories" Say Say "Usage: DISKUSE [ startdir ]" Say Say "Will use Quercus System's RexxLib if available to sort the listing" Say Say "Written by Rob van der Woude" Say "http://www.robvanderwoude.com" Exit 1 Return