Create Evernote Note With Date From A PDF Using Hazel

Create Evernote Note With Date From A PDF Using Hazel

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.

Hazel Date Rule

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.

Hazel Input Attribute

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.

Hazel Evernote AppleScript

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)

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 5 comments

Marco - August 1, 2018 Reply

Hi all
I hope I will still get a reply even though the post is a couple days ago 🙂

I have a hazle script to import my pdf to Evernote, it workes great and I get the import done. Now with the option with the atributes, it opens new doors. It would be great to use the date as a tag in Evernote.

Here is my script so far:
tell application “Evernote”
activate
create note from file theFile notebook “01 Inbox”
tag {“leistungsabrechnung”, “>assura”, “>marco”}
end tell

How can I include the atributes in the tags?

I tried this:tell application “Evernote”
activate
create note from file theFile notebook “01 Inbox”
tag {“leistungsabrechnung”, “>assura”, “>marco”, item 1 of inputAttributes}
end tell

But now no tags are applied.

Thanks for the help.
Marco

Lu - April 4, 2018 Reply

Hello Brooks
I have purchased your going paperless package and was trying to grab a pdf and send a copy to a folder called LBRnotes in evernote.
I am using:
tell application “Evernote”
activate
create note from file theFile notebook {“LBRnotes”}
end tell

But this does not seem to work.
Please could you tell me what I am doing wrong?
Thanks
Luis

Reiner Knudsen - January 13, 2015 Reply

Brooks, THANK YOU! Hazel is such a fantastic tool and these options make it even easier. I love the way you explain things. Easy to follow, easy to understand.
Now I can move batches of documents to Evernote and don’t have to bother changing their creation and modification date 🙂 I am so happy.
Cheers, Reiner.

Dave Ankers - January 12, 2015 Reply

Hi

firstly, thanks for an interesting article.

I am trying to make use of Hazel to store documents created on a Mac which already have a set of OS X tags, which I would like to replicate in Hazel.

One option is to create an Applescript with nested If…Then statements to cover all the possible combinations of tags; of course, that is ugly, error prone and static. This article got me wondering if there is any way to use InputAttributes to do this in a much more efficient way, that would also cope with new tags or combinations of tags. My first attempt is this but notes are created without any tags.

https://www.dropbox.com/s/guybzywf44lp5q1/Screenshot%202015-01-12%2010.52.38.png?dl=0

Any suggestions?

Dave

    Dave Ankers - January 12, 2015 Reply

    I should add that Tags is InputAttribute 1 and, if it is not obvious, I am a beginner at Applescript.

Leave a Reply: