This article originally appeared in TidBITS on 2007-11-14 at 5:05 a.m.
The permanent URL for this article is: http://db.tidbits.com/article/9310
Include images: Off

Clean Up Messy Folders with Hazel

by Adam C. Engst

I recently wrote about how keeping backups in BBEdit saved my bacon during a recent server crash (see "BBEdit 8.7.1 Adds Features, Fixes Bugs, Saves Data [1]," 2007-11-08). I ended the piece by commenting that I hadn't realized I was storing over 17,000 files in that BBEdit Backups folder, so I trashed everything from before 2007.

After reading about my situation, Chris Owen of Hubris Communications [2] wrote to tell me about a short cron script he runs every night on his BBEdit backups directory to delete all files older than six months, plus files older than 30 days that are also greater than 500K in size. For those who are or wish to become cron-savvy, here's what Chris sent me. (Modifying this script to work on machines other than Chris's is left as an exercise to the reader.)

#!/bin/bash
find /Temp/Backups/ -mtime +180 -exec rm {} \;
find /Temp/Backups/ -size +500 -mtime +30 -exec rm {} \;

I thought Chris's point was brilliant, but I didn't have time to wade through the Unix man pages to figure out how to set up a cron script. Besides, I've been looking for uses for Noodlesoft's Hazel [3], a snazzy little utility that watches specified folders and does things with the contents when your criteria are matched.

After 30 seconds of work in the Hazel preference pane to implement both of Chris's rules, my BBEdit Backups folder was cleaner than ever. And thanks to Hazel's constant lookout, I don't have to worry about that folder's contents growing out of control any more.

[image link] [4]
[image link] [5]

Needless to say, Hazel can match files on a wide variety of conditions, and it can do a lot more than just move files to the Trash. See the screenshot for the conditions and actions menus, which list all the possibilities.

[image link] [6]

For anyone who finds themselves needing to manage a regular influx of files - whether that management involves deleting, renaming, importing into iPhoto, or whatnot - Hazel is the easiest method I know about. Hazel 2.1.1 costs $21.95 and is available for 14-day trial; it's a 1.6 MB download and requires Mac OS X 10.4 Tiger or Mac OS X 10.5 Leopard.

[1]: http://db.tidbits.com/article/9300
[2]: http://www.hubris.net/
[3]: http://www.noodlesoft.com/hazel.php
[4]: http://www.tidbits.com/resources/2007-11/Hazel-BBEdit-cleanup.png
[5]: http://www.tidbits.com/resources/2007-11/Hazel-BBEdit-big-files.png
[6]: http://www.tidbits.com/resources/2007-11/Hazel-menus.png