How To Use Hazel Rules to Increase Productivity

The basic premise of the personal computer is to make its user’s life easier. But the mundane and repetitive computer tasks, such as sorting and moving files from the download folder, do exactly the opposite. They slow us down and distract us. Fortunately, there are applications to help us automate those tasks in the background and let us focus on what’s important. For Mac users, Hazel is the best of that bunch.

Hazel Rules Aren’t Meant To Be Broken

Hazel is a Mac System Preferences pane that watches a folder and does specified sets of actions every time certain sets of conditions are met. You can add as many folders, conditions, and actions as you want. Add the ability to run scripts to that and you have unlimited possibilities of what you can achieve with Hazel.

To start using Hazel, you need to create rules. Open Hazel in System Preferences and add a folder to watch on the left pane.

Hazel -bb- 01 - Add Folder

Then while selecting that folder, add Rules on the right pane. Rules are listed in order of importance, the first rule on the list will be run before the second, and so on. So, if you want to run A before B, put A above B on the list. You can drag and drop them to create the order.

Creating basic rule should be simple enough:

  • Give the rule a name.
  • Set the Conditions (and Nested conditions by holding the Option key while clicking the Plus button).
  • Set the Actions to do when the conditions are met.

To create similar rules, you can duplicate another existing rule and modify the content.

Diving Deep into SubFolders

One of Hazel’s cool features is its ability to watch subfolders. For example, instead of adding ten folders inside Folder A to Hazel and create similar rules for each of them, you can create master rules for Folder A and ask Hazel to apply these rules to all subfolders inside Folder A.

To do that, simply add a rule to watch subfolders at the top of Rules list for Folder A. The steps are:

  • Create a rule and give it name “Watch Subfolders” or something like that.
  • Set the condition to: Kind – is – Folder
  • Set the action to: Run rules on folder contents
  • Put that rule at the top.

After that, any rule that you add to Folder A will also be applied to all the folders inside it.

Adding Super Power with Spotlight and Scripts

To create more advanced rules, Hazel allows users to integrate Spotlight and scripts to its rules.

When you are editing a rule, you can use Spotlight attributes in rule’s condition by going to the very bottom of the list and choose Other.

The list of Spotlight attributes will pop up. You can select one of them to be the condition.

For example, you can set the condition to be valid if the item uses Verdana font.

Spotlight support means that you can use anything that can be identified by Spotlight as a condition – and it covers almost everything.

While Spotlight attributes go to the conditions, scripts supports belong to the actions part. You can use Apple Script, Java Script, Shell Script, and Automator Workflow. Translation: you can ask Hazel to do almost everything that your Mac can do.

To add a script, choose one of the script support from the drop down list, and use a ready-made script or compile it directly in Hazel.

Sneaking in Several Sample Rules

Using Hazel should be tailored to individual needs. But here are few examples of my personal usage to show you the possibilities. Please refer to this Hazel forums for more case studies.

1. Managing Desktop and Downloads Folder

Both Desktop and Downloads folder are the convenient places to drop everything, and they can be cluttered in no time. You can use Hazel to sort their contents and move the files to appropriate location automatically.

For example, you want to move downloaded TED movies files from Downloads folder to TED Talks folder inside the Movies folder. Here are the steps to create the rule:

  • Add folder Downloads to the list.
  • While the Downloads folder is selected, add a rule in the right pane.
  • Give the rule a name.
  • Under Conditions, set Kind – is – Movie and Source URL/Address – is – http://the_root_source_address_of_the_video.com/ 
    • To find out the source address, right click on one of the videos from Finder and choose Get Info (or select and use Command + I).

    • Every TED video has different download address but same root source. Don’t use the full address.
  • Under the Actions, set Move – to Folder – TED Talks. You can set different destination folder if you want to.
  • You can also add more actions, such as Add Tags and Display notification.

To do similar things to different kinds of files, create other rules. You can duplicate this rules and modify the conditions and actions, or create similar rules for different folders.

2. Processing Screenshots

I take a lot of screenshots for my writing. Before using Hazel, I took screenshots, crop/resize them to the required size, annotate them, optimize them for the web, and move them to a particular folder according to their projects. That is a very time-consuming process.

Hazel can’t take over all the steps, but it sure can streamline them. But first, I set a new workflow to support Hazel:

  • I still have to take the screenshots. I use a dedicated app to get screenshots within the required size limit.
  • I also still have to annotate the images with boxes, arrow, and text as needed.
  • But now I added an extra step when saving the image. I add a tag related to the project. For example, screenshots for project A will be tagged “A”, project B will be tagged “B”, project Beebom will be tagged “Beebom”, etc. I also set a dedicated folder to save all the screenshots.

Now this is where Hazel kicks in. I create two rules for the screenshots folder. The first rule is to optimize the image:

  • In the Conditions:
    • Kind – is – image – clear enough
    • Tags – does not contain – optimized – to make sure that Hazel will process unoptimized image only.
    • Date last modified – is in the last – 1 – hour – so that the rule won’t be applied to old screenshots.
  • In the Actions:
    • Open – with application – ImageOptim – this is the application to optimize image size in the background.
    • Add tags – optimized – to tell Hazel that this image has been optimized.
    • Display notification – file, time – this is optional.

The second rule is to move the optimized images to the right folder. Create as many variations of second rule as you need, each one adjusted to fit a particular project.

  • In the Conditions:
    • Kind – is – image
    • Tags – contain tags – optimized, Beebom – to make sure that the rule will only be applied to optimized images belong to Beebom project.
  • In the Actions:
    • Move – to folder – Beebom Projects

The combination of these two rules will ensure that all the images I save from the screenshot application will be optimized and ready in the project folder without me having to do anything else.

3. Remote-Triggering Downloads

This one is simple and fun. If you’re working with multiple computers, for example, one at home and one at the office, you can set your office computer to download a file that you find at your home computer. But we need help from Dropbox (or Google Drive).

On your home computer, copy and paste the download link into a text file. Then save the document with a unique name (e.g.: 2bdld) in a Dropbox folder (e.g.: List of Downloads).

On the office computer, create a Hazel rule that watches “List of Downloads” folder in Dropbox. Set the rule to open the 2bdld text file, without the downloaded tag, using a download manager that can accept URL input from a text file. Most download managers can do that.

Add another action in the rule to tag the note: downloaded after the download manager opens it. This action is to make sure that one text file will be opened just once.

To keep the folder clean, you can create another rule to delete text files older than one day.

4. Filing Bills into Evernote

Sometimes, living paperless means that you move your clutters from the real world to digital world. But you can file your digital bills to Evernote using Hazel and AppleScript.

Create a rule to watch the folder where you keep all your digital bills. Set the conditions to match the type of bills that you want to save. For example, if your cable TV’s bills are PDF documents from XYZ Co., set the conditions to work only for PDF files from XYZ Co.

Then add this script to the Actions pane:

tell application “Evernote”

activate

create note from file theFile notebook {“Notebook_Name”} tags {“Tag_Name1”, “Tag_Name2”, “Tag_Name3”, “Tag_Name4”}

end tell

Be sure that the Notebook_Name and all the Tag_Names are already created in Evernote.

You can create as many variations of this rule as you need for other billings or other documents.

5. Saving and Sorting Email Attachments into Mac Folders

What if your bills come via emails? Can you file sort them into Evernote without lifting a finger? Absolutely, with a little help from Dropbox, Gmail, and IFTTT.

  • First, create a filter rule in Gmail so that any billing email from XYZ with attachment(s) will be labeled “Billings”  (or any other label of your choice.
  • After that, create a folder in Dropbox called “Billings” (or any other name that you choose). You can use existing Dropbox folder for this purpose.
  • Create an IFTTT rule to connect Gmail with Dropbox. Set it to save any email with the label “Billings” to Dropbox “Billings” folder.
  • Apply the tips from number 4 above to this folder.

These five examples are just the tip of the iceberg of what you can do with Hazel. I hope you can see that your automation horizon is as far as your imagination can go.

SEE ALSO: 15 Chrome Tricks To Boost Your Productivity

Do you use Hazel? Share your favorite Hazel rules in the comment below.

#Tags
Comments 1
Leave a Reply

Loading comments...