home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Computing 63
/
ac063.adf
/
cinemorphjr.lha
/
SupportFiles
/
treesize.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-06-08
|
2KB
|
59 lines
/* *** treesize.rexx *** *
* A program to find the size of all the *
* subdirectories of a directory tree *
* recursively; May be adapted to perform *
* various operations on the tree. */
ARG dirname opts .
IF dirname = '' THEN dirname = Pragma('DIR')
IF ~Exists(dirname) THEN DO
SAY "ERROR in treesize.rexx",
"- Directory does not exist"
EXIT 10
END
s = Treesize(dirname,'',opts)
IF opts = 'QUIET'
THEN SAY 'Total size of files in tree' dirname '=' s
EXIT 0
/* Procedure that searches the tree recursively;
takes the current directory level, a "tab",
and a printing flag as arguments */
Treesize: PROCEDURE
PARSE ARG level, tab, qu
IF qu ~= 'QUIET' THEN SAY tab Basename(level)
IF Right(level,1) ~= ':' THEN level = level || '/'
subdirs = Showdir(level,'DIR')
tot = 0
DO FOREVER WHILE subdirs ~= ''
PARSE VAR subdirs newdir subdirs
newdir = level || newdir
/* =- At this point we go to next level */
size = Treesize(newdir,tab ' ',qu)
/* =- Procedure returns to this point */
tot = size + tot
END
size = file_total(level)
tot = tot + size
level = Basename(level)
IF size ~= 0 THEN IF qu ~= 'QUIET'
THEN SAY tab 'Size of files in' level 'is' size
IF qu ~= 'QUIET'
THEN SAY tab 'Total size of files in' level 'is' tot
RETURN tot
/* Basename(level) - get and highlight the level name from a full filespec */
Basename: PROCEDURE
fullname = strip(Arg(1),'T','/')
slash = lastpos('/',fullname)
IF slash = 0
THEN DO
PARSE VAR fullname dev':'dir
IF dir = '' THEN base = fullname
ELSE base = dir
END
ELSE PARSE VAR fullname +slash base
RETURN '9b'x||'33m'||base||'9b'x||'0m'
<D>