Using Hazel Rules to file by non-December year end

As a budding paperless devotee, and after reading David Spark's excellent book on the subject, I am a long way down the road of getting rid of all that paper in my life and moving things into an efficient electronic process.

I use Noodlesoft's Hazel application to do its automated filing magic, however, one area I had been struggling with was filing tax related documents into the correct tax year.  Here in Australia, our tax year runs from July to June of the following year.  This means that using Hazel to file into sub-folders by date doesn't work.  Now of course, I could just go into the yearly sub folders and pull out everything I need, but ...well I'm lazy and want it all to happen automatically!

My objective in this workflow was to keep everything within Hazel and to get around the limitation of not having 'if..then' constructs.

The Problem

The basic problem is that I need an 'if..then' hack within Hazel.  Certain receipts and files that come though my paperless system are required for my tax return.  Hazel can file these documents by calendar year by using the date matching function.  However, here in Australia, the tax year ends in June rather than December, so the problem is, how do we get Hazel to file by non-calendar year?

The Solution - Short Answer

The solution I came up with has two steps.  The first step, which is a rule watching my main processing folder, renames the file as per my date naming convention and then tags the file with the quarter (Q1 through Q4) based on that date. The file is then renamed and moved to an interim 'holding' folder. 

The second step involves a second rule (actually 2 rules) that watch the holding folder for any files with a quarter tag.  If the tag is Q1 or Q2 then the file is moved into the sub folder for the current year end (eg if the date is 23 Feb 2014, then the document will be filed in the 2013-2014 sub folder). If 'Q' tag is Q3 or Q4, then the file is filed into the subfolder for the following year (2014-2015 for example).

The Detail - Long Answer

What is Hazel

For those that haven't come across Hazel yet, it is an excellent mac OSX app by Noodlesoft that watches a folder (or folders) on your computer for any files that match a particular set of rules.  When it finds a match, Hazel can perform some pretty cool actions (some might say voodoo) on that file.  For example, if Hazel is looking for any file in my Actions folder with the word "tax receipt" in the name, I can tell it to perform some automated task(s).  When it finds a file, Hazel can rename the file to include today's date and then file it away in my tax folder with a subfolder for the current year.  Hazel can do a great many clever things that really help automating filing on your mac.

As I mentioned, my workflow involves processing everything into a single action folder.  Hazel watches this folder and files things accordingly.  For files that need to be filed by financial year, I create a rule as follows.

Open Hazel and create a new action for your Action folder.  Note: I'm assuming you have a reasonable knowledge of how to use Hazel.  If you need help, you can look at some of the articles and screen casts on Noodlesoft's website.

In this example, I'm looking for a file with 'kc receipt' in the name.  I also take advantage of the fact that the document has been scanned with OCR enabled to let Hazel look inside the document for the date.  Using the 'Contents contain match' file action, Hazel creates a variable 'DateMatch' based on the date.   I use this date variable in 2 ways.  Firstly I add a dynamic tag to the document. Secondly, I add the date to the file name.  These two steps allow me to sort the document into the correct financial year in the second part of the process.

Part 1 - Watching the Action Folder

As shown in the following screenshot, to find a date within an OCR'd pdf document, select 'Contents' from the file action drop down menu (1), and then select 'contain match' from the second drop down (2). This will bring up a dialog box. Select the date option (3) from the list. 

DateMatch.png

This will bring up the following pattern matching dialog box.  This window allows you to set up a date matching variable.

Give the new variable a name (1) - in my case I've called it 'DateMatch'. Adjust the date pattern that Hazel will look for in the document by using the various  date/time variable buttons (2). You can adjust the type of text to look for by hitting the drop down button on each of the elements (3) - for example, you can look for a 2 or 4 digit year date. If there are spaces or other characters (eg '/' or '.') in the date you are looking for, be sure to add these to the search string field. Once complete, hit the Done button.

 

It is now time to set up the file actions on any file that meets these criteria.

As shown in the following screenshot, select 'Add tags' from the Actions drop down menu (1). Select 'Dynamic Tag...' from the resulting menu (2).

Creating a dynamic tag

Creating a dynamic tag

This will being up the following window.

Give the dynamic tag a name (1) - 'QtrTag' in my case.

Select the date match variable you created above (2). We will now change the pattern of this date variable to make the tag quarter 1 through 4 (ie Q1, Q2, Q3 or Q4).

Adding a Date Match variable to the dynamic tag

Adding a Date Match variable to the dynamic tag

The following screenshot shows how to change the date pattern.  Select the drop down arrow on the date match variable (1) and then select 'Edit Date Pattern...' from the resulting drop down menu (2).

The following window will open. Select the 'Quarter' element (1) and then select the drop down menu arrow (2).  This will bring up a menu with various options for how the tag will be formatted.  Here I use the Q4 style (3).

Next, add your other filing rules.  In my case I have added a date stamp (using the same date match variable - this time with the format yyyymmdd) to the file name and then moved the document to an interim folder called Expenses (as shown in the following screen shot).

Note that these two steps are also important to help with the filing in the next phase of the process.

To summarise so far, Hazel will find a file with the words 'tax receipt' in the filename and a date within the document.  It will then tag the file with Q1 through to Q4 based on the date. The document is renamed with the date at the start (in yyyymmdd format) followed by the original file name.  The document is then moved to the Expenses folder ready for the second stage of the process.

Part 2 - Filing into Financial Year Sub Folders

The next set of rules watch the interim folder (in this case the Expenses folder) for items with a quarter tag.  If the tag is Q1 or Q2 then the document is filed into the current financial year folder, otherwise it is filed into the following financial year. 

For example, if the an invoice is dated 15 January 2014, then this would receive a 'Q1' tag from Part 1 of the process.  Part 2 will file this document into the 2013-2014 sub folder.  On the other hand, if the date is 1 July 2014, then Part 2 of the process will file the document into the 2014-2015 subfolder.

There are 2 rules that achieve this.  The following screenshot shows the 1st of these rules which is used to file Q1 and Q2 documents.

As you can see above, I set the rule to look for files without Q3 or Q4 tags. I use this 'negative selection' because I want to use the 'all' conditions option.

Since the subfolders will not have tags, I also ensure that the file type is not a folder. This stops Hazel from filing the subfolders away into another subfolder.

Finally I use the date match function to find the date of the document. In my workflow I have already put the date in the name, so I only need to look in the name.  You could just as easily look within the document (as I did in part 1 above) to find the date. 

I add the '...' variable for the name match as I know that my files will always start with the date in the yyymmmdd format and will be followed by the rest of the descriptive name.

In the file action section I

  1. Remove the tag. This is not strictly necessary, but since I don't use tags in my general workflow, there is no need to keep the quarterly tag. You could limit this to just remove Q1 or Q2 tags;
  2. I remove the any colour labels  (used in some of my other workflows) as a standard part of my Hazel workflows; and
  3. Sort the file into the appropriate sub folder, which I explain in more detail below. 

In the case of quarter 1 and 2, the objective is to file the document into the appropriate subfolder with the following naming convention:

[CurrentYear -1]-[CurrentYear]

For example if the document date is 15 Jan 2014, the subfolder will be 2013-2014. 

To achieve this we need to adjust the date using the date variable (DateMatch in this example).

As shown in the following screenshot, select the 'Sort into subfolder' action and then select the date match variable from the list of options (as explained in Part 1 above), in my case I gave the variable the name 'DateMatch'. Select the drop down arrow of DateMatch and change the Date pattern to the yyyy format.

I then added a hyphen and then DateMatch again to the folder name.  In its current form, the folder name would just be 2014-2014, so we need to adjust the date of the first DateMatch field.

To adjust the first date, hit the drop down button on the first date match variable (1 below) and then select 'Adjust date...' from the menu (2). Enter '-1' in the Years box (3) to tell Hazel to subtract a year from the date.  Now the subfolder will have the required format of 2013-2014.

A similar rule is also set up for quarter 3 and 4 files.  However, as shown in the following screenshot,

  • exclude Q1 and Q2 tags (1) in the file actions. 
  • As shown in (2) below, the subfolder name should now be [CurrentYear]-[CurrentYear+1].

The final rules should look like the following screenshot. 

Note that Hazel processes rules in the order they are listed.  This means that if you happen to put something in the Expenses folder without a Q tag, Hazel will trigger the FileQ1andQ2 rule.

Enjoy!

The Rambling Ditch Plan

Welcome to the Rambling Ditch.  As the name suggests, I plan to post my ramblings about tech things that interest me. 

Rather than just being a repost site, I will try to write more in-depth blogs on the various things that interest me.  That said, if someone says something interesting, and in a way that's better than I could, I will post a link.  In general though, what I post here are things that are have helped me, and hopefully will help improve your productivity too.

At the moment my interests include Mac and iOS with a focus on using these great platforms to improve my productivity.  My aim is to use tech to make my work more efficient so I can focus more on doing the things I like rather than being bogged down in the grind of things that have to be done, but could be done better.

I hope you enjoy my ramblings.