By Manny Fernandez

May 24, 2019

Using Hazel In My Daily Workflow

It is no secret that I run macOS. I love the flexibility.  I used to run Linux (Fedora for 4 years, and Ubuntu for 4 years) before moving to Mac.  Although I had automated a lot of task in Linux, nothing is like macOS for automation.

I use an app called Hazel by Noodlesoft.  This little app is amazing and packs a punch from an automation perspective.  In this example, I am going to show you how I process my expenses on a monthly basis.  More specifically, how I deal with my Verizon (Cell) bill and my AT&T (Internet) bill.

Lets get started.  You will need to download Hazel and install it.  It is NOT available in the AppStore due to the sandboxing requirements.

Once you install it, you will see a ‘Folders’ panel on the Left and the ‘Rules’ section on the right.

My use case is as follows:

  • I check the Verizon app on my phone and use AirDrop to send it to my MacBook Pro.  It automatically goes to my ..Downloads folder.
  • The file is always named ‘View.pdf’
  • The file contains my account number and my phone number and a date from – date to.
  • Hazel is going to monitor the downloads folder for a file named ‘View.pdf’ and if found, will change certain things, rename the file, and move it to a special folder I have.

Her we go:

2019-05-24_18-48-20.png

As you can see above,  have a ‘Downloads’ folder on the left and a rule on the right named ‘Verizon Bill – Test1’

2019-05-24_18-48-56.png

This is a very busy screenshot but it is easy to follow.  Lets break it down:

Trigger

The first thing is to choose where you want the rule to match ‘all’ meaning that there is an ‘AND’ operator between the top section triggers.  You CAN choose ‘any’ or ‘none’ depending on your needs.

  • Name is – Here we are looking for the name ‘View’
  • Kind is – Here we validate if it is a pdf file (which it always is).
  • Contents Contain – Here is where we look into the file and look for my account number that ends in 0001. (the other number are obscured for obvious reasons)
  • Content Contains – In the bill, there is a section that lists all my numbers with my name since I am the only one on my account.
  • Contents Match – Here is the tricky part and where Hazel really shows her power.

Actions

  • Rename  – This is self explanatory.  The rule is going to rename the file with the word ‘Verizon’ followed by the ‘Custom Date’ (I will show it later) followed by the extension.
  • Add tags – The rule will tag the file with a Green tag.  All my receipts and money related files are tagged with green for obvious reasons.
  • Move – The rule will then move the file to a folder named ‘Recpt’
  • Sort into subfolder – It will create a folder based on the custom date variable.

Custom Fields

2019-05-24_18-49-38.png

Here we can see that I am looking for the particular pattern.  A date range that begins with the three letter abbreviation, followed by the day, and then the four digit year followed by a space, dash, another space and then another custom range as in the first one.

On the second screenshot, you can see a ‘Preview’ button on the top right.  This is a great tool that allows you to validate if the rule will match.

2019-05-24_18-50-54.png

You can see that Hazel prompts you for a file to test against.  Choose the file and select ‘Open’

2019-05-24_18-51-28.png

If all is well, you will see the Green circles with white checkmarks show up.  The output above shows that we matched all of the triggers.

That is it.  Hazel can be integrated with other applications by using AppleScript or Java Script.  I have a script I use to automatically OCR files that are put into certain folders.

By having one of the actions as ‘Run AppleScript’ and adding this small script

tell application "PDFpenPro"
open theFile as alias
tell document 1
ocr
repeat while performing ocr
delay 1
end repeat
delay 1
close with saving
end tell
quit
end tell

You can automatically OCR PDFs when they meet certain triggers (e.g. source folder, name, etc)

 

Hope this helps.

Recent posts