A program I wrote over the weekend

drivedist2I have a fairly large hard drive. This doesn’t keep it from eventually getting full, nor would it if I bought an even bigger hard drive. In reality most people only clean out their hard drive when they need it.

The question is: how do you find unwanted files? By definition, unwanted files should be those that you don’t use and if you don’t use them you’ve probably forgotten about them a long time ago. This was definitely true for me.

I really needed some kind of program that could point me to big chunks of unwanted files. But it’s impossible for a program to know what files you don’t want to keep, however it could at least point you to big files.

So I’ve designed a tool that scans a directory on the hard drive and gathers size information about every file in it (including subfolders). Then it sorts everything by size and visualizes the “weight” of all the files and folders. Once the scan is complete you can navigate through the folder structure and tag items for deletion.

This very simple program has already pointed me towards folders that I didn’t even know existed. I found a bunch of old podcasts and videos in my iTunes folder. Threw those away. I then discovered that a media server I’ve used (TVersity) had secretly downloaded podcasts and YouTube videos on its own. 4 gigs right there! I never looked in the TVersity folder because the program itself is really small.

Scanning a deep folder structure with hundreds of thousands of files will take quite a while, in the magnitude of 10ths of minutes. This is due to the limitations of the hard drive and file system and there wasn’t any way for me to code around it. I did notice however that the scan runs much faster a second time, most likely due to caching by the operating system. Because it takes so long I wrote it as a threaded app, with one UI thread and two scanning threads. I’ve started to get quite comfortable using threads lately.

I’ve had accidents when coding file deletion into my programs before, so this time I’m merely moving files to the recycle bin for verification and permanent deletion (emptying) by the users.

One Response to “A program I wrote over the weekend”

  1. Cedric said:

    Jan 17, 10 at 14:05

    I like you artistic touch even in the siemplest program you make :)
    When it comes to clean my disc I use windirstat (http://windirstat.info/)
    It has the same features as yours, and also display a 2D block map of the harddrive.


Leave a Reply