OS2 World.Com Forum

Subject  :  How to use REXX program to check directory size ?
Author  :  Sam
Date  :  19 Oct, 2006 on 19:47
I would like to write REXX progrm to check for size of particular directories.

Is there any utilies / command that can fullfill this requirement ?

Thanks in advance.


Subject  :  Re:How to use REXX program to check directory size ?
Author  :  mobybrick
Date  :  20 Oct, 2006 on 01:27
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:


Subject  :  Re:How to use REXX program to check directory size ?
Author  :  melf mikaelelf@os2ug.se
Date  :  20 Oct, 2006 on 09:18
In eCS, at least from version 1.1 there is a function, if you rightclick on a folder, called "show tree size" (Folder actions>show tree size). You get info of folder size but also size of files, and some other info.

---
/Mikael

Subject  :  Re:How to use REXX program to check directory size ?
Author  :  mobybrick
Date  :  20 Oct, 2006 on 15:08
I know, but I think Sam wanted a REXX program to do it...

Subject  :  Re:How to use REXX program to check directory size ?
Author  :  melf mikaelelf@os2ug.se
Date  :  20 Oct, 2006 on 16:31
..suspected that..but just had to mention..

---
/Mikael

Subject  :  Re:How to use REXX program to check directory size ?
Author  :  Sam
Date  :  22 Oct, 2006 on 12:22
Moby, Mikael,

Thanks for the help. I want to implement that in an legacy (Pre eCom) OS/2 system.


Powered by UltraBoard 2000 <www.ub2k.com>