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.
The 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 1Obviously 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 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.
For 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.
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.