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

  • If you've spent any time configuring user authentication on... Full Story

  • DNS is one of those technologies that quietly underpins... Full Story

  • BGP issues on FortiGate firewalls usually trace back to... Full Story

  • Every time your laptop talks to your router, a... Full Story

  • If you've spent any time configuring NAT on a... Full Story

  • If you have spent any time configuring firewall policies... Full Story

  • High availability on FortiGate is one of those features... Full Story

  • If you've configured SD-WAN on a FortiGate, you've almost... Full Story

  • FortiLink is the management protocol that turns a FortiSwitch... Full Story

  • FortiSwitches are pretty rock solid from Mean Time Between... Full Story

  • This is a quicky tip.  Have you ever gone... Full Story

  • DNS is one of those quiet pieces of internet... Full Story

  • This article is an updated version of the previous... Full Story

  • You will add ns2 as a secondary (slave) BIND9... Full Story

  • In the process of deploying my lab, I needed... Full Story

  • RFC 8805, used to be known as Self-Correcting IP... Full Story

  • Years back, I wrote an article about certificate pinning. ... Full Story

  • FortiGates have the ability to send alerts to Microsoft... Full Story

  • In this post, I am going to walk through... Full Story

  • Troubleshooting VoIP on a FortiGate can feel like trying... Full Story

  • Prior to FortiOS 7.0, there were three commands to... Full Story

  • In this post, I am going to go over... Full Story

  • What we are going to do:  We are going... Full Story

  • Choosing between FGCP (FortiGate Clustering Protocol) and FGSP (FortiGate... Full Story

  • Creating a VLAN on macOS (The "Pro" Move) A... Full Story

  • This blog post explores the logic behind how macOS... Full Story

  • Pretty Fly for a Wi-Fi Tell My Wi-Fi Love... Full Story

  • Part of my daily gig is creating BoMs (Bill-of-Materials)... Full Story

  • ICMP introduces several security risks, but careful filtering, rate... Full Story

  • The command diag debug application dhcps -1 enables full... Full Story

  • In the world of FortiOS, execute tac report is... Full Story

  • LLDP; What is it The Link Layer Discovery Protocol... Full Story

  • What it actually does When you run diagnose fdsm... Full Story

  • Monkey Bites are bite-sized, high-impact security insights designed for... Full Story

  • I have run macOS in macOS with Parallels but... Full Story

  • Don't be confused with my other FortiNAC posts where... Full Story

  • This is the third session in a multi-part article... Full Story

  • Today I was configuring key-based authentication on a FortiGate... Full Story

  • Netcat, often called the "Swiss Army knife" of networking,... Full Story

  • At its core, IEEE 802.1X is a network layer... Full Story

  • In case you did not see the previous FortiNAC... Full Story

  • This is our 5th session where we are going... Full Story

  • Now that we have Wireshark installed and somewhat configured,... Full Story

  • The Philosophy of Packet Analysis Troubleshooting isn't about looking... Full Story

  • Replacement messages are the pages and text blocks that... Full Story

  • If you sell into government, defense, healthcare, or finance,... Full Story

  • Accurate time is one of those infrastructure fundamentals that... Full Story