“Don’t repeat yourself” is a cardinal rule of programming. It’s meant to admonish programmers against manually running the same segment of code repeatedly when computers can do that sort of thing automatically. But you don’t have to be a programmer to avoid repeating yourself. If you’re a Mac user, Hazel will help you organize your files automatically, increasing your efficiency and freeing your mind from the obnoxious drudgery of shuffling bits around by hand.
What Is Hazel?
Hazel is a macOS application that provides an easy-to-use graphical interface for some fairly advanced scripting capabilities. It functions on a fairly simple “if this, then that” sort of structure, meaning that it matches specific parameters to specific files, and then performs a task if those parameters are met. While the logic is simple, you can chain together a bunch of complex functions to make sophisticated programs and then set them to run whenever you’d like.
Setting Up Hazel
Hazel is easy to set up. After you’ve downloaded and installed the application, you’ll find it in your System Preferences. Click on the icon to open the preference pane, and you’ll be able to get started.
When you first launch the pane, you’ll be in the Info tab which tells you whether or not Hazel is currently running and gives you some other information. You’ll see a button that says “Start Hazel,” but leave it off for now. If you start it now, all your rules will apply the moment you save them, which may not be what you want if you’re just getting started.
However, do make sure to tick the box below that says “Show Hazel status in the menu bar.”
On the left side of the window, you’ll see a column with a list of folders. Click on one of those folders, and you’ll see the pane on the right, labeled “Rules,” fill up with some checkboxes. These demo rules are included in Hazel and are currently disabled but can be useful as inspiration.
1. Clean Your Downloads Folder Regularly
I tend to use my Downloads folder as my “on deck” directory. As such, it gets crammed with files that were once important but are now useless. Fortunately, we can create a very simple rule to help us solve that problem.
1. To create a new rule in Hazel, first click on the folder you want Hazel to monitor in the Folder sidebar. In this case we’ll be using the Downloads folder. Then, click the plus button.
2. Give your rule a title that clearly explains its function.
Now we’ll set up our criteria.
3. Click the drop-down menu labeled “Name,” and change it to “Date Last Opened.”
4. Click the drop-down menu labeled “is,” and change it to “is not in the last.”
5. Change “1 hour” to “7 days,” or whatever interval of time you feel comfortable with.
In the next section, we’ll set what to do with files that match our criteria.
6. Click “no folder selected,” and change it to “Trash.”
7. To save the rule, click OK. If Hazel is turned on, that rule will apply immediately after you click OK, so any files older than seven days will be moved to the trash.
This is perhaps the simplest possible Hazel rule, but it’s still useful. I actually use a few in conjunction, which move and trash files at different times based on their type and age. Here’s a screenshot of my current Downloads rules with titles that should give you an idea of what they do.
2. Organize and ZIP Old Files
This rule I use to organize my Desktop comes in two parts. First, we’ll set up a rule that puts old files into a specific folder.
1. Click on your Desktop folder in the sidebar. If the Desktop folder isn’t there, click the plus button under the list of folders.
2. Click in the plus button in the rules pane to create a new rule.
3. Change your Name drop-down to “Date last modified,” “is not in the last,” and change the time interval to one week.
4. Change the Move drop-down to “Sort into subfolder.”
5. Click the text box after “with pattern” to bring up a list of renaming tokens you can use. Select “current date.”
6. Click after the current date token in your text box and type “archive.”
7. Click Done to close the text box and OK to confirm the rule.
Now we’ll set up as a rule to compress those folders into ZIP archives.
8. Create another new rule in the Desktop folder by clicking the plus button under the rules list.
9. Create two rules: Name contains “archive” and Kind is folder.
10. Click the action drop-down to select Archive.
This rule will automatically archive everything that hasn’t been modified in the last seven days.
3. Rename and File Scanned Documents Based on OCR Content
This last rule requires some external hardware or software to make it work. I use my ScanSnap which converts scanned documents into PDFs with live text data embedded. This way I can automatically file scanned paperwork into the appropriate folders.
By now, you know how to read this rule. It matches three conditions, using the contents of the PDF as triggers for the actions below. When it finds a match, the rule renames the folder with the date the scan was created and the name of the bill, and files it in my “Statements” folder.
Once you’re done creating all your rules, you can return to System Preferences and turn Hazel on.
As you can see, Hazel is incredibly powerful, and the three rules above are just examples. Take the time to muck around and experiment, and you’ll be sure to come up with something handy.