Hi,There are probably better ways of doing it, but I knocked this up for you. Include the two functions Digit: and Get_DirSize in you code, and then you can call Get_DirSize to get the directory size of the specified directory. If you need to calculate the size of the tree, then you will need to modify the code to do /S.
There is probably a REXX DLL to do this somewhere, but this will work for the moment...
Yours,
Moby.
/* OS/2 REXX */
/*Test*
say 'Size of C:\ is 'Get_DirSize("C:\")
signal end
Get_DirSize: Procedure
myline=''
DirSize = "ERROR"
do while queued() <> 0; parse pull; end;
cmd="@dir "arg(1)". 2>nul | rxqueue 2>NUL 1>&2"
cmd
do while queued() <> 0
myLine = lineIN( "QUEUE:" )
if abbrev( reverse( myLine ), reverse( "bytes used" ) ) then
DirSize = word( myLine, 3 )
end
DirSize=translate(DirSize)
i=length(DirSize)
tempstr=DirSize
j=0
multi=0
tempchar=''
DirSize=''
do while j \= i
j=j+1
tempchar=digit(tempstr,j)
if tempchar = 'K' then multi=1
if tempchar \= '' then if tempchar \= ' ' then if tempchar \= 'K' then if tempchar \= ',' then DirSize=DirSize''tempchar
end
if multi=1 then DirSize=DirSize*1024
RETURN DirSize
digit: Procedure
/* Returns specified digit in supplied string. Use is string, position - where position starts from 1 */
/* if arg(2) > length(arg1) then return '' */
leftstr=left(arg(1),arg(2))
return right(leftstr,1)
end: