(view source code of freespace.rex as plain text)
/* Display blank line */
say
/* Check for command line parameter (none required) */
parse arg params
if params <> "" then call Syntax
/* Initialize RexxUtil library */
if RxFuncAdd( 'sysloadfuncs', 'RexxUtil', 'sysloadfuncs' ) = 0 then do
call sysloadfuncs
end
else do
call Syntax "RexxUtil"
end
/* Retrieve list of local drives */
drives = SysDriveMap( "C:", "LOCAL" )
/* Check file system type of each drive */
chkdrv.0 = 0
do until drives = ""
parse value drives with drive drives
drvtype = SysFileSystemType( drive )
if ( drvtype <> "" & drvtype <> "CDFS" ) then do
j = chkdrv.0 + 1
parse value SysDriveInfo( drive ) with chkdrv.name.j chkdrv.free.j chkdrv.total.j .
/* Srip trailing backslash */
chkdrv.name.j = " "||strip( chkdrv.name.j, "T", "\" )
/* Calculate free space as a percentage of total space */
chkdrv.perc.j = ( ( 100 * chkdrv.free.j / chkdrv.total.j ) + 0.5 ) % 1
/* Convert KB to GB */
chkdrv.free.j = ( ( chkdrv.free.j / ( 1024 ** 2 ) ) + 0.5 ) % 1
chkdrv.total.j = ( ( chkdrv.total.j / ( 1024 ** 2 ) ) + 0.5 ) % 1
/* Increment array index by 1 */
chkdrv.0 = j
end
end
/* Display header */
say "Drive: Size: Free: % Free:"
say "====== ===== ===== ======="
/* Format screen output */
do i = 1 to chkdrv.0
say left( chkdrv.name.i, 6, " " )||,
right( chkdrv.total.i, 10, " " )||,
right( chkdrv.free.i, 11, " " )||,
right( chkdrv.perc.i, 13, " " )
end
/* Done */
EXIT 0
Syntax:
errcode = 0
parse arg errtype
if errtype = "RexxUtil" then do
errcode = 255
say "Error: RexxUtil could not be loaded"
say
end
say "FreeSpace.rex, Version 1.00"
say "Display size and free space for each local drive of the local computer"
say
say "Usage: <REXX> FreeSpace.rex"
say
say 'Where: "<REXX>" is your Rexx interpreter:'
say " - Windows: REGINA.EXE with RexxUtil installed"
say " (RexxUtil is not compatible with REXX.EXE)"
say " - OS/2: no need to specify, just rename script to *.cmd"
say
say "Returns: On screen table with sizes and free space in GBs"
say
say "Written by Rob van der Woude"
say "http://www.robvanderwoude.com"
EXIT errcode
return
page last modified: 2024-04-16; loaded in 0.0070 seconds