Finding and Freeing wasted space in OS X

It doesn’t seem to matter how big of a hard drive you have, it will eventually fill up. Many times just seeing which directory is using the most space can help you find space that can be freed. For example, the other day I was running low on drive space, but looking at the size of several directories, I noticed that my download directory was over 10 GB. I turned out that I had downloaded several Linux ISOs and burned them to DVDs, but forgot to erase the downloaded files. Just seeing that the size of the directory was abnormally large made it easy to free up the space. This article is going to look at several ways to look at the size of directories in OS X.

Figuring out how much data is being stored in a particular directory seems like a simple problem, but from the standpoint of the operating system, it is surprisingly difficult. Basically the idea of a folder that contains files and other folders is a concept created for the users and has very little to do with the way data is actually stored on the hard drive. For the operating system to figure out how much data is in a particular folder, it has to look at every file in the folder, add the size to a running total, and then present the result to the user. Since each folder can contain other files and folders, this process can involve looking and hundreds and even thousands of files.

Folder SizeThe simplest way of finding the size of a folder is to simply select the folder and press Apple + I. This will pop up an informational window that contains a field labeled size. If the folder has a bunch of information in it, the computer may need to do some calculations before it can give you an answer. This method is great if you want to just find the size of one folder. If want to look at the information for several folders, just select all the desired folders and push Apple + I. This will bring up an info box for each selected folder. Obviously this method isn’t good for checking the size of more than a few folders simultaneously because you’d end up with your entire screen full of Info windows.

The next way you can check the size of folders is using the command line shell. Bring up the terminal (usually located in your Utilities folder under applications). The du command will give you the disk usage for a particular item. By default it will show you the disk usage for your current directory recursively. Recursively means it will show you all the information for and sub directories and sub sub directories of your current directory. For simplicity we’ll tell the command to only show 1 level deep. This is done by using the -d 1 switch to only show a depth of 1. Here is the command and result:

$ du -d 1
35735224 ./Movies
27834488 ./Music
9526128 ./Pictures
40 ./ScriptTools
332960 ./Sites
Obviously that isn’t very useful. We can get better information by telling du to make its report human readable with the -h switch. So the results look like:

$ du -d 1 -h
17G ./Movies
13G ./Music
4.5G ./Pictures
20K ./ScriptTools
163M ./Sites
This makes it much easier to find out which folders are taking up the most space. By setting the -d option to a different depth you can get information about the folders deeper down in the heirarchy.

Disk Sweeper IconFor people who don’t want to deal with the command line there is a program call OmniDiskSweeper. This little program comes in a free version (which lets you view your file system along with the size of each file or folder) and a $15 version (which adds a delete button so you can erase files without needing to find them in the finder). The application can be started by clicking on the icon or by selecting it from the Services menu in the Finder. This makes it easy to find the size of a particular folder and subfolders without needing to go find the program in the Applications folder.

Omni Disk Sweeper Screen Shot

Since the program still has to wait for the operating system to check the sizes of each file and folder, the program may take a little while to run. The numbers change as the size is calculated.

These three methods will all accomplish about the same thing, but each of them is useful in different situations.

5 thoughts on “Finding and Freeing wasted space in OS X”

  1. Anyone know of a good free tool (or even a command) to list directory sizes on a PC? I sure hope they’ll integrate this feature into Windows Vista.

  2. I found very useful tool, called whatsize (you can find it in , its free and its good!!!

    For windows there is one called treesize…..

  3. If you eschew the -h flag you can feed the output of du into sort -n to give a sorted list of the smallest to largest files e.g.

    du -d 1 | sort -n

    My own favourite version of this command is,

    du -s * | sort -n

    It takes a while to finish but gives a sorted list of the sizes all the files and directories in the current directory. Be patient, it usually takes a while to complete for directories of any reasonable size.

    On windows I always install cygwin which gives me a UNIX like shell where I can us du as above.

Leave a Reply