(view source code of filesize.cmd as plain text)
/* FileSize, Version 1.00 */
/* Cloned from the Norton Utilities for DOS */
/* Check total file size, space used and slack for specified files */
/* Copyrights (C) 1999, Rob van der Woude */
/* Initialize RexxUtil */
if RxFuncQuery( "SysLoadFuncs" ) <> 0 then do
call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
call SysLoadFuncs
end
/* Initialize Quercus System's RexxLib */
if RxFuncQuery( "RexxLibRegister" ) <> 0 then do
call RxFuncAdd "RexxLibRegister", "rexxlib", "RexxLibRegister"
call RexxLibRegister
end
parse upper arg files destdrive"/"options
if options = "?" then call syntax
destdrive = strip( destdrive )
S = ""
if left( options, 1 ) = "S" then S = "S"
if files = "" then files = "*"
call SysFileTree files, "dummy.", "BO"
if dummy.0 > 0 then do
srcdrive = filespec( "D", dummy.1 )
end
else do
curdir = directory( )
newdir = directory( files )
srcdrive = filespec( "D", newdir||".\" )
newdir = directory( curdir )
end
srcclust = dosdisk( "S", srcdrive ) * 512
if destdrive <> "" then do
if length( destdrive ) <> 2 then call syntax
if substr( destdrive, 2, 1 ) <> ":" then call syntax
drvletter = substr( destdrive, 1, 1 )
if drvletter < "A" then call syntax
if drvletter > "Z" then call syntax
destclust = dosdisk( "S", drvletter||":" ) * 512
end
call SysFileTree files, "files.", "F"||S
totalsize = 0
totalspace = 0
desttotal = 0
slack = 0
_files = files.0
if files.0 > 0 then do i = 1 to files.0
parse value files.i with fdate ftime fsize and_the_rest
totalsize = totalsize + fsize
totalspace = totalspace + fsize
desttotal = desttotal + fsize
if totalsize // srcclust > 0 then do
totalspace = ( totalspace % srcclust + 1 ) * srcclust
end
if destdrive <> "" then do
if desttotal // destclust > 0 then do
desttotal = ( desttotal % destclust + 1 ) * destclust
end
end
slack = format( 100 - ( 100 * totalsize / totalspace ), 2, 1 )
end
say
say " "||files
numfilemsg = " "||_files||" file"
if _files <> 1 then numfilemsg = numfilemsg||"s"
say numfilemsg
say " Total file size is "||totalsize||" bytes"
say " Total space used is "||totalspace||" bytes"
say " "||slack||"% slack"
if destdrive <> "" then do
drvinfo = SysDriveInfo( drvletter )
freespace = word( drvinfo, 2 )
drivesize = word( drvinfo, 3 )
say
say " "||drivesize||" bytes total on drive "||drvletter||":"
say " "||freespace||" bytes free on drive "||drvletter||":"
say " "||desttotal||" free bytes needed on drive "||drvletter||":"
if freespace < totalspace then do
say " Insufficient free space on drive "||drvletter||":"
end
else do
say " Sufficient free space on drive "||drvletter||":"
end
end
exit
syntax:
say
say " FileSize, Version 1.00"
say
say " Usage: FILESIZE [ filespec [ target_drive ] ] [ /S ]"
exit
return
page last modified: 2024-04-16; loaded in 0.0055 seconds