Automate tasks with Hazel
Learn how to use the powerful tools that lurk behind Hazel’s simple interface
Learn how to use the powerful tools that lurk behind Hazel’s simple interface
Most of us know two facts about housekeeping; it’s necessary and it’s incredibly dull. We know that clearing files and folders from the desktop, emptying caches, archiving documents and sorting out iTunes is important to keep our Macs running smoothly. But, frankly, who has the time, or come to think of it the inclination, to spend hours weeding out files and then filing, trashing or renaming them?
For some, of course, this isn’t an issue. If you’re a whizz with AppleScript, or love creating new Automator workflows, you can automate much of the process and let it run by itself without ever having to worry about it again. Most of us, of course, are not AppleScript geniuses and while we can get our heads around Automator, we often don’t have the time to sort it out.
Fortunately for us there are a few third-party apps which can help, and one of our favourites is Hazel.
Hazel is a System Preferences pane and, optionally, a menu bar icon. It has two states: on and off. When it’s running, it will execute all the rules you have created and set to run. Once you’ve created rules, you can check and uncheck them to dictate whether or not they execute when Hazel is turned on.
One thing worth noting is that while Hazel runs in the background, many of the tasks it carries out make visible alterations to your Mac. So, for example, if you have a rule which periodically examines the desktop and sweeps files into a subfolder inside your Documents folder so you can deal with them later, you’ll notice the files suddenly disappear from your desktop when the rule is executed. This can be disconcerting, but it’s nothing to worry about. It just means Hazel is doing its job properly.
The other thing to note is that Hazel executes your rules on a folder by folder basis. So when you create a rule, you first need to specify the folder to which the rule should apply. If you want a rule to act on every file, no matter where it’s stored in your user account, however, you can choose your home folder.
There are lots of sample rules to help you get started when you first install the app. It’s worthwhile opening them up and poking around to see how they are put together. That will allow you to see how rules are constructed and give you ideas for creating your own.
To load the sample rules, click on Hazel in the bottom group in System Preferences, or select Open Hazel… from Hazel’s menu bar icon. Next, click on a folder in Hazel’s left-hand pane, and then click on the gear icon at the bottom of the window. Now click ‘Load Sample Rules’. Click on any rule in the right-hand pane and then click the pencil icon at the bottom of the window. You can now see exactly what the rule does and the parameters it uses. To add extra conditions or actions, click on one of the ‘+’ buttons to the right of an existing condition or action.
The construction of rules will be familiar if you’ve ever built a Smart Playlist in iTunes. You start with one condition and one action, and you can add more. You can match against all, any or none of the conditions, and add additional groups of conditions – such as to exclude unwanted files that share certain attributes – by holding å and clicking the ellipsis (‘…’) button that appears next to your existing conditions.
Hazel has one other trick up its sleeve: it manages your Trash. Under its Trash tab are several options. You can elect to delete everything that’s been in the Trash for more than a week, or tell Hazel to keep your Trash folder below a certain size. You can also set it to delete all the files associated with an app when you trash that app, which saves you creating a Smart Folder to find those files or even buying a dedicated app to do that job. Kenny Hemphill
Who has the time to spend hours weeding out files and then filing, trashing or renaming them?