• Home
  • /
  • Blog
  • /
  • How To Use Hazel To Automate Your Repetitive Tasks
Household Broom For Floor Cleaning Leaning on Brick Wall

When we do an internal poll of the Asian Efficiency team or ask our Dojo community for their favorite apps to be productive, there is one that is always near the top of the list: Hazel.

It is one of our key applications to free up time, eliminate annoying manual tasks, and make the macOS experience better. It is consistently in the top 10 of our Essential Apps list every year.

(By the way, it is a Mac automation app, but there is a similar Windows automation app called File Juggler. More on that below.)

Hazel’s popularity is well-deserved: dealing with files is a pain. Who wants to be manually renaming and moving file after file? And when we don’t do it, we end up with a mess of unorganized and unfindable digital files. There has to be

What Is Hazel?

Now that we’ve hyped it up, the natural question is: “what the heck is it?”

Noodlesoft, the creators, describes it as “Automated Organization for Your Mac”, and that is a great tagline.

Essentially, you tell the Hazel app to watch a folder (or multiple folders), set some rules you want it to watch for, and when something happens in that folder that matches one of your rules, take an action (or actions) that you define.

To use the app correctly, you just have to understand very basic if-then logic. In other words:

If X-condition(s) are true, then do Y-action(s).

For example, you can set up rules like the following:

  • If a file is in the Downloads folder and is bigger than 1GB and hasn’t been opened in 1 week, then move it to the trash folder or an external drive.
  • If the file name contains “invoice”, then color it green and make a copy in the Finance folder.
  • If a file on the Desktop hasn’t been opened in the last 24 hours, move it to a “Desktop To Review” folder.
  • If a screenshot file is saved to your desktop, rename it and move it to a special folder.
  • Automatically import copied photos and videos to your Photos library.
  • Import a downloaded .ICS file to your Calendar.
  • If a PDF has been downloaded that is your business American Express bill, rename it and file it away to the correct location. Then create a task in your task manager to remind you to pay it.

There are so many ways you set up rules. They can be very simple, or you can have multiple conditions and multiple actions so you can really make it as complex as you want it to be.

You can even run shell scripts or Applescripts, so what you can do with your files is almost unlimited. If you don’t know what any of that means, not to worry — no programming is required. Anyone can learn it.

What About Hazel For Windows?

While there isn’t a Windows version, there are alternatives. File Juggler is a popular tool that can do a lot of what Hazel can do. You should be able to do many of the tasks outlined here on Windows with File Juggler.

Want A Hazel or File Juggler Automation Quickstart?

We’ve put together Digital Declutter, a quick and easy automation resource that will take you step-by-step through automating files on Mac and Windows with Hazel and File Juggler. There are easy to follow videos that will walk you through at your own pace.

Click here to learn more about Digital Declutter.

Why Automation Matters

Why use a tool like Hazel at all? Here is a comment from an Asian Efficiency reader that is by no means unusual:

I’ve been trying Hazel for the past few days with the trial, and I just don’t get it. It seems that it’s for people who don’t know what’s going on with their file system. I don’t need something to monitor my download folder and move things to other folders automatically – I move things to where they should go myself. Sorry, I just don’t get it – Hazel causes more problems than it solves IMO…

Many people who try automation tools like Hazel and TextExpander don’t “get it” at first. How hard is it to rename, move, or manipulate a file? How hard is it to type?

At Asian Efficiency, we live by something called the “3 Times Rule.” If something bothers you 3 times, find and implement a permanent solution for it.

This can apply to things that don’t bother you too. If you find yourself doing repetitive tasks manually that could be automated or outsourced, why not find a solution to take it off your plate? Awesome Asian Efficiency reader Scott says it well:

Look for areas in your workflow where you find yourself doing repetitive tasks with files, then see if there is a way to have Hazel help automate that for you so that you can get on with bigger and greater things. It’s not just about maintaining your file system, but also about automating tasks to free up your time and attention.

The value of freeing up time and attention for things that actually matter can’t be overstated.

(By the way, automation doesn’t just mean technology. Here’s a guide to 5 ways you can automate your life that takes the concept beyond file management!)

Using Hazel: Quick Wins

Let’s look at some quick wins that will get you started.

When you install the software on your Mac, it automatically adds your Downloads folder and installs some sample rules. It’s highly recommended that you poke through those rules and get a feel for how a rule is set up before starting with your live important files.

If you ever want to get to your rules, click on the broom icon in your menu bar and choose Open Hazel….

Open Hazel

The key thing to know about the Hazel Mac app interface is that it is split into three sections: Folders, Rules, and Rule Details. Once you get that, using Hazel is easy.

Hazel Interface

The Folders section on the left is the list of the folders on your Mac that you want to watch. To add a folder, drag it into that window from the Finder or click the + button to add it.

The Rules section on the right lists the rules you have set up for the selected folder. Hit the + button to add a new rule or click on an existing rule to view/edit it.

Let’s start with a few simple rules.

Clear Off Your Desktop

The Desktop can be a convenient place to temporarily store files, but it can quickly become a cluttered mess. We’re going to create a rule that moves any file that hasn’t been opened in one day to a folder called “Desktop To Review”.

If you’d like, you can delete the untouched files, but we’ll be safe and sweep them to a folder to look through later.

Hazel Desktop

First, we’ll (1) add the Desktop folder by hitting the + button in the Folders pane or dragging it in. Then, we’ll (2) hit the + button in the Rules pane to add a new rule.

Hazel Desktop Image

Next, we’ll tell Hazel that we want to:

  • Watch for any files that were created more than a day ago
  • Ignore folders (we only want to look at files)

We also tell Hazel we want it to:

  • Move any of these files to the “Desktop To Review” folder

One we hit OK to save it, here it is in action:

Hazel sweep

Here is a similar rule in File Juggler, for Windows users:

File Juggler Desktop

Automatically move and clean up old screenshots

The Mac has a handy built-in screenshot feature (if you haven’t tried it yet, hit ⌘-Shift-5, and select part of the screen).

By default, these screenshots get stored on your Desktop. You can delete or move them yourself, but why not let Hazel do it for you so you don’t need to think about it?

If you’d like, it can delete them for you, but I like holding them in a folder (~/Pictures/Screenshots) for a while just in case.

Here’s a rule that will move screenshots older than an hour:

Hazel Screenshots

This is great, but now you’ll have a ton of screenshot images in ~/Pictures/Screenshots.

Not a problem. You can make a second rule to delete very old screenshots. If you collect all screenshots in a separate folder but never empty it, you’re wasting a lot of space. So make sure you make a new rule for your screenshot folder that deletes files older than, say, 4 weeks.

Add the Screenshots folder by pressing on the plus sign in the folders pane (or drag the Screenshots folder in), then add this rule:

Hazel Remove Old Screenshots

Here is a Windows version in File Juggler:

File Juggler delete old screenshots

Clean Up Your Downloads Folder

Over time your Downloads folder can become a mess and can take up a lot of space. Here are some strategies for taming it.

Remove DMG files

When you download and install a Mac app outside of the App Store, more often than not you will download a DMG file.

Once you install the application, you probably don’t need that DMG file anymore. If you’d like, you can to sweep them away to another folder or to an external hard drive. In our case, we’re going to create a rule that deletes them after a day.

Hazel remove DMGs

Sweep Old Files

Similar to what we did with the Desktop, you can keep your Downloads folder clean by moving old files to another folder for further review, or (if you’re brave) you can delete them.

Follow the instructions for “Clear Off Your Desktop” above, but create the rule for your Downloads folder.

Sort Your Downloads

If you like things to be nice and organized, you can automatically sort files into subfolders by criteria like date, extension, or type. Here’s how to keep your downloads folder sorted by type for files older than 1 day.

Hazel sort into subfolders

To select kind, click into the with pattern box. You’ll see you have a number of different options. The date ones can be particularly handy.

Hazel sort by type

Here’s the rule in action:

Hazel sort into subfolders

Here is a similar rule using File Juggler on Windows:

File Juggler sort into subfolders

For more tips on naming and organizing your files check out our blog post on this topic.

Highlight Mac Apps You Never Use

How often have you tested out an application on your Mac and then never used it again? This rule will use the handy Set color label feature to highlight the apps we may want to get rid of.

If there’s any application in the Mac /Applications folder that hasn’t been opened in a year, it will turn it purple.

Hazel highlight old apps

If you then sort your /Applications folder by Tag, you can quickly see which ones should be reviewed. It looks like I have a bit of cleaning to do.

Hazel tagged applications

Clean Out Your Trash

Many of us are not the most diligent at cleaning out the Trash on our Mac. This is great if you need a file later, but not so great if you want to save hard drive space.

Assuming you have an effective backup system in place, you can monitor your Trash and clean it out periodically or when it gets to a certain size. Let’s clear out the Trash every two weeks.

This time we won’t be creating a rule, but adjusting a setting. Go to Hazel > Preferences and go to the Trash tab. Check the Delete files sitting in the Trash for more than checkbox, and set the time period you want to keep files for.

Just remember, once files are gone from the Trash, they’re gone. Be careful with this setting.

Move Saved Email Attachments

Hazel can be a handy tool for archiving files received via email.

If you want to save your important attachments outside of your email program, you can save them to a central folder and then set up rules for Hazel to move your attachments for you.

We wrote about how to handle email attachments, and that article gives an example of doing this.

Move Old Zoom Recordings

You might have an application that creates recordings or backup files that can build up over time. Two for me are Zoom and Audio Hijack. Just to be safe I don’t want to delete the files, but I don’t want them cluttering up my precious hard drive space either.

You can set up a rule to leave them on your hard drive for a specific period of time but then whisk them away to an external hard drive.

If you do local recordings, Zoom can eat up a lot of space. Just these seven recordings take up 2.72 Gigs of space.

Hazel zoom recordings

You’ll notice that Zoom stores its recordings in folders. So we will use that to build our rule.

First I’ll add my Zoom folder, which for me is ~/Documents/Zoom.

Then I’ll watch that folder for any folder that was created more than two weeks ago. Once it finds one, move it to a “Zoom Store” folder which is on an external hard drive.

Zoom recording Hazel rule

That’s all there is to it. Zoom recordings will hang around for 2 weeks and then I will get that sweet sweet Mac SSD space back.

(Side note: If you’re like most of us and are getting burned out from all these Zoom meetings, check out our podcast about how to beat Zoom fatigue.)

Hazel Power Moves

We’ve gone through some quick wins you can achieve with Hazel, but it’s time to take things to the next level. Here are some more technical examples of what you can do.

Paperless Automation: Automatically Move Documents

Hazel is an absolutely killer tool for processing your paperless documents on your Mac.

(File Juggler is great on Windows too.)

We recommend creating a central folder to act as an inbox and have everything you can and download go to that folder.

Then you can watch that folder and automatically rename and move your PDFs based on the rule you set up.

You can have it move and rename based on the name of the document, but you can even have it look inside the PDF at the contents and move and rename based on text inside the document. It can even grab the date out of the PDF and use that in your file name (!).

We’ve written about using Hazel with your paperless documents before, so check out that detailed tutorial.

That workflow is good, but if you want to make use of the date in the PDF, you’ll need to set a criteria for Contents and then contain match. Choose Custom Date.

We’re creating a token here, and call it stmt date.

In most cases, you can leave Automatically detect date format checked and Hazel will do the work for you.

If that doesn’t work, you’ll have to build your own custom date. Uncheck the Automatically detect date format checkbox.

Use Month, Day and Year to build the pattern that Hazel should look for, but the key is that the pattern must match the date format in your PDF.

For example, if you had a bill with a date that looks like this:

Then your Hazel token would need to look like this:

Hazel custom date

Things like spaces, slashes, and commas matter. This can be a pain to get right, but once you do it is extremely powerful.

Once you have your token saved, you can use it in the Rename step. Going off the example from our paperless article, here is what the new action section would look like:

Hazel custom date rule

Now it will grab the date from the bill, use that date in the name, and rename it with our naming convention and move it.

Here is a similar rule using File Juggler on Windows:

This takes so much of the heavy lifting out of going paperless.

Rename downloaded files

If you download statements, reports, or other files, they are probably not named in the format you want. Fortunately, Hazel can help.

For example, my bank has a report where the downloaded file is named eStatementyyyy-mm-dd.pdf, where yyyy-mm-dd, of course, the date of the report.

I want the file to be named yyyy-mm-dd-XYZ Bank.pdf instead. In plain English, what I want to do is:

Get rid of everything before the date, use the date, and then tack -XYZ Bank after the name.

No problem. There are many ways to do this, but let’s do it the name-manipulation way and do it in a way that we are being extra-safe that it will grab the right file.

Create a new rule and for the criteria, set it to Name and matches. Click into the white matches box and you will see a popup.

Hazel name

In this box we will be telling Hazel to do two things:

  1. Look for a file named with a certain pattern.
  2. Grab part of that file name and put it into a token so we can use it later.

First, we want to tell Hazel to look for a name starting with eStatement. Click on the dot beside Custom text. It will open up yet another popup, and this time we want to give our token a name (this one doesn’t really matter) and in the Type text field, I have eStatement. This has to exactly match what we’re looking for in the file.

Hazel name matches

Hit Done.

Next we want to create another token for the part of the filename that contains the date. If we wanted to manipulate that date we could use the Custom Date type, but in this case let’s keep it simple and just use Custom text again. Click on the blue dot beside Custom text.

This time we are going to keep it low tech. We want to tell Hazel that we want it to look for the part of a file that has a number, then a hyphen, then another number, then another hyphen, then another number.

Hazel date token

I gave it a name “stmt date”. Hit Done.

Here’s what my Matches popup looks like:

Hazel tokens

Hit Done.

Now that we have our matching done, we’ll tell Hazel to rename the file. For the action, choose Rename and get rid of the part of the filename that says name. We don’t care about the exiting name.

Instead, click on the “stmt date” token we created earlier and then type -XYZ Bank after it. Here’s what my rename pattern window looks like:

Hazel rename pattern

Now when I save the rule, Hazel will look for anything named eStatementyyyy-mm-dd and rename it to yyyy-mm-dd-XYZ Bank.

As I mentioned, there are other ways to do this (especially with PDFs), but I wanted to show you the power of tokens and how you can use them to take information from one place and use it in another.

Create new task in OmniFocus when a PDF bill arrives

A common worry when going paperless is making sure bills are paid on time — how can we remember to pay our bills if we don’t see them sitting there?

The Asian Efficient way is to set up auto-pay, but for some bills you can’t or choose not to.

A solution is to set up Hazel to watch a folder for your bills, and then have it create a task in OmniFocus to remind you to pay it.

This can be done with an AppleScript, and this old MacSparky blog post can help you do that.

The Preview Button Is Your Best Friend

When you are building complex rules it can be helpful to test as you go along. Thankfully, Hazel has a Preview button to help.

Let’s go back to our file-renaming rule from earlier. We’re going to tell Hazel to look at a document that we think should match the rule. We do that by hitting the Preview button, which will either say Preview or look like an eye, depending on your version of Hazel.

Hazel preview button

Once you hit the button, choose the document you want Hazel to watch and hit Open.

Right away you’ll see a green checkmark beside each step that the sample document matches.

Hazel preview matches

In this case, it matches. So we should be good to go!

If a step doesn’t match, there will be a red x.

You can double-click on one of the red x’s and it will tell you what part doesn’t match and what it sees instead. You then have something to investigate.

Hazel Preview Match Detail

Copy Tax Receipts

When you’re downloading a receipt (or you captured it with your phone and uploaded it to Dropbox), you can have Hazel watch a folder, watch for a part of a name, and then move and rename it. This can be handy for tax receipts.

When I am saving a document, I might want it to go to my normal filing system, but I might also want it to go to a Dropbox folder that I share with my bookkeeper. I do that by having a Hazel rule look for anything that has “-taxbd” at the end.

Hazel tax receipts

By now this should be pretty standard Hazel for you. Look for a file that’s name ends with some text, and copy it to a folder. The key is that little icon you see in the name attribute in the Rename with pattern box.

When you (1) click on one of the attributes, you have some options. In this case, I (2) chose Replace text.

Hazel replace text

In this case, I’m telling Hazel to replace -taxbd in the file name with blank text, effectively chopping it off. This way I get the benefits of using this text to tell Hazel to do something without it cluttering up my file names.

Automatically Resize Images

If you are constantly having to resize images to a certain width, you can set up a folder and have Hazel watch it and do the resizing for you.

Now, Hazel itself can’t resize images, but this example shows how the power of Hazel is almost unlimited. We’re going to have it run a shell script and do the resizing for us.

I created a “To 800” folder, and created a Hazel rule that looks for images. I like to put in a safeguard and have it only run if the Pixel Width is greater than 800. Pixel Width isn’t one of the default options. First choose Other… and then scroll down or search. You’ll find it.

Hazel image size

Next it’s time to do a tiny bit of scripting. In the action section, choose Run shell script. Then click on Edit script.

Now you have a script window opens up. Paste or type in this command:

sips -Z 800 "$1"

sips is a command built into macOS and $1 is what Hazel will use to substitute in the file it is working for.

Hazel shell script

Now Hazel will watch for any image you drop into To 800, check if it is greater than 800, and if so run sips to resize it.

(Hat tip to Jacob Salmela for this tip.)

Automatically Import To Evernote

Note: This section will not work if you are using (at the time of writing) Evernote 10.x on the Mac. Evernote (hopefully temporarily!) removed AppleScript support. If you need the ability to automatically import to Evernote, you will need to install the Legacy Evernote version.

For some reason, the Windows version of Evernote comes with import folder functionality, but Evernote for Mac does not. Never fear though, as a Hazel expert, you can make your own.

We’ll create a To Evernote folder and create a Hazel rule that uses AppleScript to add to Evernote.

Here is, at a high level, our rule:

Hazel move Evernote

Now let’s click on Edit script to see the magic.

Hazel Evernote AppleScript

It’s pretty simple. Here’s the AppleScript code to paste in:

tell application "Evernote Legacy"
	activate
	create note from file theFile
end tell

theFile is Hazel’s placeholder for the file it is processing.

If you have problems with it, sometimes you need to change the first line to:

tell application id "com.evernote.evernote"

You can do a lot more with this, like automatically adding tags or moving it to specific notebooks. Here is Evernote’s AppleScript reference if you want to get really geeky.

Only move non-secure PDFs to Evernote

Sometimes we may want to copy documents or other files to Evernote, but don’t feel comfortable storing sensitive information there. Here is one way you could protect yourself:

Hazel move Evernote

This is the same as the last rule, and uses the same AppleScript. But now it has a condition where it will only copy the file to Evernote if it does not contain one of the account numbers listed. You can list social security numbers, credit card numbers, account numbers, or any other sensitive text you wouldn’t want uploaded to Evernote.

Match Using Custom Lists

Sometimes you may want to evaluate your files against a list of items. It could be a list of customers, a staff list, a product list, or anything.

The list can be short and you can type it into Hazel directly, or it could be a longer list contained in a file.

Either way, Hazel can use that list to evaluate your match, and even better, you can then use the matched item from the list to rename your file or take another action.

When you create your rule, choose matches as the action, and then choose the Custom List Item element.

Hazel custom list element

Either type in your list, or choose the file to use. You can see I typed my simple list and then named the list TeamPH.

Hazel custom list

In my case, my filenames have text before and after my match that I don’t care about, so I will surround my element with an “Anything” element.

Hazel Match Anything

I then used my new TeamPH element in the rename step, so if a file matches the list (in other words, has one of the list elements), it will then use that matched name in the result. Here’s the whole rule:

Hazel Match List Rule

You’ll see that the paystubs from the people in the list were renamed and moved, but the paystubs for Thanh and I (who were not on the list), were not. Success!

Hazel List Finder Results

Match Using A Custom Table

Lists are one thing, but let’s take things one step further. Let’s say you receive invoices from your accounting system, but they are exported just with the Customer ID. You want them renamed to the customer name.

Sure, you could make a bunch of Hazel rules saying “rename to X if filename contains customer ID Y”, but we can do one better — we can use a CSV that we have with our Customer IDs and Customer Names.

This time, instead of manually typing the data into table in Hazel (which you can do), we’re just going to point Hazel to this CSV:

Hazel table list

Like the List, we will use Name matches as our criteria, but this time we will choose Custom Table.

This time instead of leaving it as embedded, we will choose from file and navigate to our customer list. We want to match on Customer ID.

Hazel import file

The files will start with the Customer ID, so we will keep that first and add an “Anything” after it, We don’t care about the rest.

Now when we add our Rename step, we will add the Customers element to our name, and choose Customer Name, which is a field from our table.

Hazel rename with customer name

Here’s our whole rule:

Here’s our list of files starting with the Customer ID. What do you think will happen?

If you guessed they’d be renamed with their appropriate Customer Names, you would be correct!

Hazel after table rename

What Will You Do With Hazel?

Believe it or not, we are over 4,800 words and we have barely scratched the surface of what Hazel can do.

If you’d like more examples of things you can automate using technology, make sure to check out our podcast episode 5 Examples of Tasks You Can Automate To Save Yourself An Hour a Day. We talk about how we use Hazel, as well as many other automation technologies.

We also have a short course that comes loaded with Hazel rules and templates to declutter your computer so you don’t have to set it up yourself. Check out Digital Declutter for that.

If all these examples are overwhelming, just pick one to implement, play around, and get to know the tools. You can implement the other ones later if they would help you.

Do you have any killer Hazel workflows you’d like to share? Is there anything you wish you knew how to automate but don’t know how? Leave a message in the comments below.

Invitation

Do you want to know how to set up your workplace and your computer to get more done? Are you interested to know how you can structure your ideal day and build routines? If you answered yes to both or even just one, then join our FREE TRAINING by clicking this link. It is absolutely 100% free.


You may also Like

Last Updated: March 14, 2023

Read More
Read More

Last Updated: December 11, 2020

Read More

ABOUT THE AUTHOR

Brooks Duncan

I love taking technical topics and translating them so that they make sense to non-nerds. I'm a Chartered Professional Accountant and have been a software developer and have run software support in very small startups and extremely large public corporations. I strive to be relentlessly helpful in everything that I do. I live in Vancouver, Canada and insert extra u's in many of my words.


Leave a Reply


Your email address will not be published. Required fields are marked

  1. hi Duncan
    quick question about hazel/juggler. does the software allow for the moving of files across to other fileservers. i need to create a daily automated task that will move pdfs from one fileserver to another and then delete any other file formats in that folder to the trash?

  2. I’ve had hazel a few years now and even after reading this i still believe you need to be a level 10000 coder there is no simple way to use this program unless you write code for the FBI AND CIA. I’ve tried sample folders to test and still cant get this crazy thing to work. Honestly I like hazel but its a waste of money without a 10,0000$ coding training class. This blog just didn’t help. even simple things like watch a folder go into sub folder get images and move to a single folder is difficult to get hazel to do, well damn near impossible unless you work at NASA.

  3. I’ve been using Hazel for years for PDF filing and you just showed me I’m a rank beginner. Time to start really using Hazel. Thank you. :)

  4. Thank you, thank you, thank you!!! I’ve owned Hazel for a couple years now and I never really took the time to dive in. This write up gave me the inspiration to get my hands dirty writing rules (and using some of yours).

    I have a question. As a photographer, I create nested folders using the same naming convention (ie Date_Client_ProjectDescription_ShootLocation_CityState) over and over again for each project. Is there a way for Hazel to help with this or should I use automator or possibly try some scripting? Any help would be much appreciated

  5. Thanks for this great write up. I’ve had Hazel for years and have struggled to take advantage of it.
    The thing I find most repetitive in my workflow is that I upload a lot of documents to cloud storage like Box, GDrive and Amazon drive. I don’t have them all set to sync because I don’t want copies on my local drive.

    Is there a way to program Hazel to watch a folder and upload documents meeting certain conditions to that cloud folder?

    If not, what would you recommend as a workaround?

    Thanks!

  6. Fantastic.

    I am curious to know if there is another automatic app that you would recommend or is Hazel your go-to? I ask this because I am wanting to compare the two, side by side.

    Thank you.

    Joel

  7. Most informative and useful write-up of Hazel I have ever come across. Too many are happy to show me how I can scan the gas bill and get it automatically filed, but this article provided me with many things I can put to work-at work. Thorough, but an easy read, with really helpful screenshots. Epic article!

  8. Have started reading through many of the blog posts here … … you need a search function and a list somewhere. Really hard to find stuff if you are reading over several days.

    Keep up the good work, and thanks

    Tim

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}