home *** CD-ROM | disk | FTP | other *** search
- /* DIRSIZE - (C)1992 Turgut Kalfaoglu <TURGUT@FRORS12.BITNET>
- For OS/2 2.0
- Version 1.1 - corrects a missing 'end' statement
-
- DIRSIZE will summarise the disk utilisation of your files and
- directories.
-
- This program creates three files showing:
- -> all files on drive, sorted by filesize
- -> all subdirectory totals, unsorted
- -> all subdirectory totals, plus bar graph, sorted
-
- Usage:
- -> Make the drive you want examined default,
- -> type DIRSIZE from any OS/2 prompt. It will create three
- files in the root directory of your drive: SORTED.DIR,
- SUMMARY.DIR and GRAPH.DIR. Warning: Old versions of these
- files or files with the same name will be erased!
- -> If you are not interested in having your whole disk
- sorted, run program with the NOSORT option.
-
- Requires:
- -> OS/2 2.0
- -> OS/2 SORT utility.
-
- */
- Arg parms
- nosort = pos('NOSORT',parms)>0
-
- /* These are the outputs from the program: */
- outfile = "\SORTED.DIR"
- sumfile = "\SUMMARY.DIR"
- grafile = "\GRAPH.DIR"
-
- Call RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree'
-
- Say time() '-- START: Erasing output files --'
- 'DEL' outfile sumfile grafile
-
- Say time() 'Reading directories'
- rc = SysFileTree("\*.*",s,"BS")
- Say time() s.0 'items loaded.'
- if rc > 0 then exit rc
- if nosort = 0 then do
- Say time() 'Sorting files by size. This may take a little while.'
- offset = s.0 % 2
- do while offset > 0
- limit = s.0 - offset
- switch = 1
- do while switch \= 0
- switch = 0
- do i=1 to limit
- x = i+offset
- if word(s.i,3) > word(s.x,3) then do
- switch = i
- t = s.i
- s.i = s.x
- s.x = t
- end
- end
- limit = switch - offset
- end
- offset = offset % 2
- end
- end
- Say time() 'Outputing to' outfile
- do i=1 to s.0
- rc = LINEOUT(outfile,s.i,)
- end
- rc=LINEOUT(outfile,,)
-
- Say time() 'Summarising directory sizes..'
- sizecount. = 0
- dirs = " "
- max = 0
- maxlen = 0
- do i=1 to s.0
- parse var s.i date time size attrib filespec
- parse var filespec disk':'dir
- x = lastpos('\',dir) /* parse filename now.. */
- dirname = left(dir,x-1)
- filename = substr(dir,x+1)
- if dirname = '' Then dirname ='ROOT'
- sizecount.dirname = sizecount.dirname + size
- if pos(' 'dirname,dirs)=0 then dirs=dirs dirname
- end
- Say 'You have' words(dirs) 'directories. Writing to' sumfile
- odirs = dirs
- do words(dirs)
- parse var dirs dirname dirs
- disp = dirname
- if length(disp)<20 then disp=left(disp,20,'.')
- size = sizecount.dirname
- if length(size)<12 then size=right(size,12,'.')
- blurb = 'directory:' disp 'consumes' size 'bytes.'
- rc = LINEOUT(sumfile,blurb,)
- max = max(max,sizecount.dirname)
- maxlen = max(maxlen,length(dirname))
- end
- rc = LINEOUT(sumfile,,)
- dirs = odirs
- maxstars = 78 - (maxlen+10+3)
- Say time() 'Creating' grafile 'with this chart:'
- do words(dirs)
- parse var dirs dirname dirs
- x = ''
- stars = trunc(sizecount.dirname / max * maxstars)
- if stars < 1 then iterate
- do i=1 to stars
- x=x'*'
- end
- blurb = left(dirname,maxlen) right(sizecount.dirname,12) x
- say blurb
- rc = LINEOUT(grafile,blurb,)
- end
- rc = LINEOUT(grafile,,)
- Say time() 'Sorting' grafile
- 'SORT /R /+28 <' grafile '> CALC$.TMP'
- if rc\=0 then exit rc
- 'ERASE' grafile
- 'COPY CALC$.TMP' grafile '/V'
- 'ERASE CALC$.TMP'
- Say time() '-- END: Successful completion --'
- exit
-
-