Hazel Date Matching And Choosing The Date To Match

Hazel Date Matching And Choosing The Date To Match

Hazel Date TokenLast week I was overjoyed at Hazel 3.1’s ability to do date matching, and I have been migrating my Hazel rules over to use this great new functionality.

One question was on my mind though: what happens when the document has multiple dates?

Default Date Behavior

I decided to do a test using one of my documents. For example, I have a statement with a date range like so:

Statement Date Range
Statement Date Range

I set up my Hazel rule as per David Sparks’ excellent screencast, and ended up with my date token:

Hazel Date Token
Hazel Date Token

In the “Do” section of the rule, I had it attach the reformatted date to the beginning of the file name:

Hazel Date Rule
Hazel Date Rule

As I suspected, the rule worked and it appears to have used the first date that it found, which in our case is 05/01/2013.

Hazel Renamed PDF
Hazel Renamed PDF

Choosing Your Hazel Date

I couldn’t find any way to have Hazel choose which date to use. However, awesome DocumentSnap reader Carsten Langrock had a great suggestion on Twitter: while we can’t choose the date, there are often words around the date that we can use to isolate it.

For example, take a look at my statement again. If I want 5/31/2013, there is that TO_ in there.

Date Range Highlighted TO
Date Range Highlighted TO

What would happen if I modified my Hazel token and put a TO and then a space before the date? That way, Hazel should consider that whole string when looking for the date.

Hazel Token With Text
Hazel Token With Text

What do you know. It pulled the date we were looking for and renamed the PDF appropriately.

Hazel PDF with Right Date
Hazel PDF with Right Date

This isn’t going to be possible with every PDF, but it should work for many of your documents if you are a bit creative.

Bonus lesson: if you want to see what Hazel sees when it looks at your documents, check out this ridiculously low tech way to extract text from a PDF.

Do you have other tricks for date matching with Hazel 3.1? Let us know in the comments. Thanks!

About the Author

Brooks Duncan helps individuals and small businesses go paperless. He's been an accountant, a software developer, a manager in a very large corporation, and has run DocumentSnap since 2008. You can find Brooks on Twitter at @documentsnap or @brooksduncan. Thanks for stopping by.

Leave a Reply 3 comments

sandy - October 31, 2014 Reply

Very helpful. Thanks!!

Justin - July 31, 2013 Reply

I searched online for over two hours, looking up unix commands and applescripts. I got this done in under five minutes after reading this. You are amazing.

David M - July 2, 2013 Reply

Just perfect. I just asked myself the same question.

Leave a Reply: