After watching my Go Paperless With Hazel Webinar, awesome DocumentSnap reader Kyle Lines had a question: is it possible to use Hazel to grab a date from a PDF, create a note in Evernote, and use that date as the note’s creation date?
He had an AppleScript most of the way there, but it wasn’t quite working.
“No problem”, I thought. A combination of Hazel’s date matching abilities and some AppleScript goodness would be simple, but there was one problem.
Traditionally there has been no way to use Hazel to pass information in to an AppleScript without a weird hack like renaming the file or Spotlight comments.
While I was figuring all this out, Kyle came up with the solution on his own and was kind enough to share it with the DocumentSnap audience. It uses the new abilities in the just-released Hazel 3.3 to be able to pass an attribute in to a script. Total game changer. Take it away, Kyle!
In order to create an Evernote note with the bank statement date as the creation date and modification date, I first have Hazel search for “Contents” “containing match” of a custom date as seen below.
I then had Hazel rename the statement, and then ran an AppleScript. Before building the script, I added an input attribute, my custom date that was pulled from the contents of the document in the step above.
Finally, I built this script. This tells Evernote to create a note titled as seen below into the notebook I want with the tags I want (I just have one on this one, but I have multiples on others, hence the brackets). I then told it to set the creation date of the note to item 1 of the input attributes list (my custom statement date). And because I’m a little OCD about it, I have it to set the modification date of the note to the creation date so they are the same.
Here’s the script for your copy and pasting pleasure:
tell application "Evernote"
activate
set note1 to create note title "USAA Checking Statement" from file theFile notebook "Financial" tags {"Bank Statements"}
set (creation date of note1) to item 1 of inputAttributes
set (modification date of note1) to (creation date of note1)
end tell
I have used this now with modification on every single one of my bank statements, bills, etc. and I have found no issues with it. Try it out and let me know how it goes.
Thank you so much for this Kyle, this is completely awesome and a great use of Hazel’s bleeding edge features and AppleScript.
(Photo by Vladimir Kostka)