Running out of space ? What's on your disk?

Often a hard disk gets close to full and undesirable things happen, especially on the volume that contains Windows. For example, suppose Windows Update is chugging along and runs out of space. How does it gracefully handle that?

How can you determine which folders take up the most space?

This recursive code creates a cursor with 2 fields per folder: the full path and the size.

CREATE CURSOR dirs (path c(250),size n(13,0))


SELECT * FROM dirs ORDER BY size descending INTO CURSOR totals

BROWSE FIELDS path,size:p="999,999,999,999" NAME oBrowse LAST NOWAIT


PROCEDURE dodir(cPath) as Number

      LOCAL n,i,aa[1],nTotal



      FOR i = 1 TO n

            IF "D"$aa[i,5]

                  IF aa[i,1] != '.'

                        nTotal= nTotal+dodir(cPath+aa[i,1]+"\")



                  nTotal= nTotal+aa[i,2]



      INSERT INTO dirs VALUES (cPath,nTotal)



The last parameter to ADIR preserves the CasE of the names. Notice the formatting of the large numbers with commas makes them much easier to read. The NAME clause of the BROWSE command creates an object named oBrowse which can then be manipulated, such as invoking the Autofit method.

Hidden, compressed, inaccessible (perhaps due to security) files, junction points can vary your results.

This SQL statement groups folder by folder depths (number of backslashes) and shows how many and how big they are.

SELECT OCCURS("\",path) as dep,COUNT(*),SUM(size) FROM dirs GROUP BY dep

My disk had folders 14 levels deep!