You know how sometimes you come across a tip that is so clever you are both happy to have learned it and annoyed that you didn’t think of it yourself at the same time?
It is well known that I love a little Mac app called Hazel that allows you to create rules to perform almost any function on your computer. One great use of Hazel is to move all the PDFs that you are downloading from the web now that you are going paperless.
Katie’s tip is to use the Source URL of the downloaded PDF as a basis for doing the processing. Brilliant! Have no idea what on earth I just said? No worries, I’m about to go through it.
Where Was That PDF Downloaded From?
You may not know this, but when you download a PDF from the web, it has the address that it was downloaded from embedded in the file.
The easiest way to see this is to highlight the file in Finder and hit Command-i. It will bring up the Info window, and look under the “More Info” section.
You’ll see a bunch of junk in there including this:
Obviously the URL that you downloaded it from will be there, not mine. Since we have the URL embedded, we can use it to do stuff later.
Create A New Rule In Hazel
Fire up Hazel, and if you haven’t already, add the folder that you download PDFs to in the folder on the left. Then we want to create a new rule, so hit the Plus button in the right column.
Create The Conditions
Now lets give the rule a name, and create the conditions that Hazel will use to figure out which file to act on. The conditions we’ll use in this case are:
- File type is PDF
- Source URL is scotiaitrade.com
Again, substitute your own domain. Here’s the screenshot of the conditions:
Figure Out What To Do With The File
In all likelihood, the filename that your bank or vendor uses is totally useless. Sure you could type it in yourself when you save it, but we are trying to be as automated as possible here.
What I am going to do is:
- Rename the file using the convention yyyy_mm_dd-name-type.pdf
- Move the file to my Statements folder
Obviously use your own naming convention and move it to wherever is appropriate for you.
Before the screenshot, I know some of you are going to ask “How do I move it to Evernote?” It is your lucky day, I already wrote a post about how to send PDFs to Evernote using Hazel so you can combine the two.
First in the Do The Following section, I will change it to Rename File, and the default pattern it gives you is “name” and “extension”. We’ve already established that the name is no good, so delete it.
Drag “date created” up to the pattern section, and it will look like this:
Take a look at the example at the bottom. That is not the date format that we want, so click on date created and choose Edit Date Pattern. The yyyy mm dd looks good, but click into the box and replace the dashes with underscores.
Hit Done and now the date format is looking good. We just need to give the file a name. In this case, I know that any PDF that I download from scotiaitrade.com is going to be my RRSP statement. So, for this rule, I want the file to be called yyyy_mm_dd-ScotiaiTrade-RRSP.pdf.
Click into the pattern box and just type in “-ScotiaiTrade-RRSP” between “date created” and “extension”.
Next we want to move it. Click the plus sign beside our rename rule, and create a Move rule that moves it to your folder.
Here’s the final rule:
Click OK, and if you want to see if this will work, click on the little gear icon on the bottom and choose Preview Rule Matches. Looks like it should work!
Depending on the other Hazel rules going on, it may take a while to kick off. If you’re impatient, you can run it manually by clicking on the Hazel icon up in your menu bar.
And look, there it is in my Statements folder:
Lets Get Geeky(-er)
For 90% of normal people, the above will work fine. There is only one problem that I know will drive me crazy.
The statement that I am downloading today (in February) is actually January’s statement, and having that February date in the filename will just not do. Unfortunately, I don’t believe that Hazel has the functionality to do any sort of date math, so for me TextExpander will have to come to the rescue.
If you are not familiar with TextExpander, it is a Mac application like Hazel: you don’t really think you need it until you have it, and then once you have it you can’t imagine life without it. Basically, it allows you to type in small snippets of text and have them expand (get it?) to longer ones.
In this case, what I am going to do is take the renaming step out of the Hazel rule and then set up a TextExpander snippet to do the filenaming for me. I am not going to go through the ins and outs of TextExpander in this post but here is a screenshot of my rule:
That looks super-ugly (don’t let it scare you off TextExpander, most rules wouldn’t be like this), but basically %@-1M%Y_%m_%d-ScotiaiTrade-RRSP is saying “subtract one month from today’s date and format it as yyyymmdd”. Now when I type ,its, TextExpander automatically turns it into 2011_01_15-ScotiaiTrade-RRSP.
So if you are still following along, my updated workflow is:
Download PDF > When the Save As box pops up, type ,its which automatically sets the filename with a date one month ago > Save it to Downloads > Hazel sees it, looks at the Source URL, and automatically moves it to Statements.
What About Tags?
I personally use tags for my documents, so the next logical step would be to have Hazel assign OpenMeta tags to the documents. However, that is getting a little geeky even for this post. If it is something you’d like me to post about, drop a note in the comments and I will put something together.