Hazel Is Your Personal File Manager

Last Updated on

The classic Mac automation program, Hazel, is a powerful resource for filing and managing files, including pictures, PDFs, and documents.  In my case it’s documents—specifically invoices and letters. Hazel does the dirty repetitive work of managing my documents so I don’t have to.

Read on to learn about one of my most favorite, and little known Hazel tricks. Mac Automation Tips readers also get a 10% off code for my Hazel video tutorial.

It’s a bit annoying that we get differently labeled invoices from so many companies. If you ask me, my life would be much easier if we didn’t have to pay for things, but we do.

However, and the invoices companies send out are far from “standardized”. Whereas the electricity company sends Invoice December.pdf, the phone company sends something like BFB5A7E3-F3F1-439D-963F-39B9C5CED62D.pdf. Whatever all those letters mean, this is not really helpful when it comes to searching for the file.

Luckily we have our Macs, and moreover we have Hazel. Hazel uses Spotlight underneath to find data inside of files. This gives us the opportunity to use that (meta-)data to do things with it. That sounds good. Let’s try it.

hazel guide cover

Subscribe to Download FREE Guide for Setting Rules In Hazel

  • Hazel provides full automation in the background. 
  • My guide provides several rules you can set up even it's your first time using Hazel.

Download Hazel

This article assumes that you have some familiarity with Hazel, but in case you don’t, you can download a 14-day trial version Hazel, and follow along with this tutorial.

To get started, activate Hazel, which you will find not in your Applications folder, but in System Preferences, in the third-party applications folder.

Create a New Rule

In the left column, add (+ button) a new Finder folder for where your designated documents will be added, such as your Downloads folder, or a folder within your Home Documents.

Next create a new rule for that folder but this time click the plus button inside of the added folder—on the right hand side.


Setting Up a Rule

Whenever you use contain match in a condition, the text field on the right side comes up with a nice popover where we can specify what to match for. contains match is available from almost any attribute.

An attribute is the thing we search for, e.g. name, creation date, document kind.

First we’ll try to match our electricity companies’ invoices very specifically using any of the metadata fields available. In this case I’d match for:

  • Name starts with "Invoice"
  • Kind is "PDF"
  • Contents contain "Electricity Inc."


The third option here searches in the document for the text “Electricity Inc.”.

Note the difference between the simple contain and contain match. contain match gives the ability to create so-called tokens. These tokens can be reused in the actions below.

But contains match is actually even smarter because we can search for a dynamic text—rather than a fixed one. This means that we can “describe” text portions to search for.

We can, for example, open one or two of those invoices and compare the invoice numbers. Let’s assume for this example that the invoice number of our December invoice is:


With a dynamic pattern we can go ahead and search for (pseudo example):

6 digits, followed by a dash, followed by another set of 5 digits, a hash symbol, and another digit.

Just drag the single digit from the bottom up to create something that looks like this:


When you click OK at the bottom of the new rule, and then preview by clicking the eye button, you should see a match in the window, and a couple of seconds later a notification. (Notice how I set the action to only “Display notification”. I do this whenever I test new rules.

Learn the power of “custom text tokens”.

That’s pretty cool, you might say, but actually the really cool thing is that we can create custom text tokens. These are bits of text, just like the one we just created, but they are contained inside a token. These tokens can then be used to rename a file, sort into a subfolder, or make a notification pop up. You can hopefully see where we are going with this.

Drag the Custom Text token (the • token) up, and give it a name. It should look like this:

Hazel rule

On the bottom (the actions) choose rename and drag the Invoice Nr token to the name. This will rename the file to the text token we have defined above. To summarize: we are searching for a dynamic text, inside the file, and use that text to rename the file itself. More workflows below.


Other Examples

Of course you can add more text to the name and get even fancier with filing. Here are a couple of examples for your inspiration:

  • Rename the file like so: year-month-day - issuer - invoice nr.pdf
  • Find invoice year and invoice month as separate text tokens in invoice, and sort into subfolder by year → month.
  • Automatically open files in OCR app, rename, and file the result.

Personally I’m also adding specific tags to files from my electricity company, phone, etc., and then sort into subfolder by year, and then month.

Special Offer 

If you like this tip, check out my Hazel Video Tutorial to learn all you need about this nifty app. Mac Automation Tips readers get a full 10% off with the code MACAUTO16 until February, 14th 2016.

GET ACCESS TO SUBSCRIBERS-ONLY  Mac Automation Resource Library
%d bloggers like this: