Sending Files to Evernote While Creating Tasks in OmniFocus

As is well documented on this site I:

All of my text files are stored in nvALT and most other files are stored in Evernote (larger files live in Dropbox).

Now all of this is well and good, except for one small thing… I wasn’t doing the upfront work on filing. Over time, I’d either:

  • Toss files into a single folder on the desktop;
  • Leave them in my downloads folder.

And active files, well, they would just live on the desktop. For the most part this was an effective system, as it kept most things “out of site, out of mind,” but I’d run into plenty of situations where I had to go looking for something that should have been filed away in Evernote, but wasn’t.

Geek Phase I – Automatically Filing Using Hazel and Evernote

So, as most geeks do, I made a few changes that improved my workflow by:

Now, when a file on my desktop is properly named (i.e. Workx – File Name – 13–01–24), Hazel sees that little “x – ” bit and works its magic. Since making this change, I haven’t tossed a single file into a random folder and no longer store anything in a downloads folder that I never think to check. Everything is where it’s meant to be: still on my desktop, properly stored in Evernote or, best of all, in the trash.

Geek Phase II – Adding These Files to OmniFocus

Much as this change was an improvement, I couldn’t help but notice that the increasing number of files that were building up on the desktop. Traditionally, only files I was actively working on would live there, but since there was no folder in which to throw things, files for future actions/projects started piling up.

As I’ve shared in the past, I’m a bit nuts about keeping my digital desktop neat (this probably has a lot to do with my struggles to keep a physical one tidy). So the answer was obvious, but clunky: throw the files into Evernote, then create a task in OmniFocus with a link to the note. This worked, but required a multi-step process that involved naming the file, opening Evernote, selecting the right note and then using a Keyboard Maestro macro to pull the note into a new task in the OmniFocus clipper. Not bad, but not ideal.

So I did what most geeks who don’t know how to code do: I whined about this to smarter nerds. In this case Brett Kelly, Nick Wynja and Justin Lancy were kind enough to help me figure out how to use AppleScript to get the link to a newly created Evernote note. Once I combined this with some AppleScript that Ken Case provided in a previous post and tweaked my Hazel rule, magic started happening. Any file that has “- of ” (i.e. Workx – File Name – of – 13–01–24) in addition to my naming convention is sent to Evernote and a task is created in the OmniFocus Clipper with a link back to the note. My desktop is clean once more and my files are easily accessible, either for reference or use in a task.

Geek Phase III – The Little Details

I’m not quite done with this. My skills are very limited (and Justin is having fun watching me struggle to finish the job), but I’d like to get it so the additional “- of ” is removed from the file name before it gets saved into Evernote and added to my task. That said, I figure this is at a stage where you might benefit from it as well (even though you’ll probably need to make some changes to suit your own needs).

While I’m sure this will be updated periodically, here’s the code (or you can just download it here):

set myNote to {}
set noteLink to missing value
set AppleScript's text item delimiters to {" - "}

tell application "Evernote"


--CREATE THE NOTE set myNote to create note from file theFile


set myName to (filename of attachment 1 of myNote)


--PAUSE UNTIL THERE IS A VALUE FOR NOTE LINK repeat while noteLink is missing value --GET THE NOTE LINK FOR THE CURRENT NOTE set noteLink to (note link of myNote) end repeat

end tell

– These are the parameters you might want to tweak set TaskName to second text item of myName set TaskNote to noteLink

– Here is the script code itself tell application “OmniFocus” tell quick entry — open the quick entry window open — Create a new inbox item set NewInboxItem to (make new inbox task with properties {name:TaskName, note:TaskNote}) — Expand the note so it’s visible in the Quick Entry window set note expanded of last leaf to true — Start editing the task name select last leaf — Select the new item activate — Make the app active so it gets our scripted keystrokes delay 0.25 — Give it a chance to activate tell application “System Events” if UI elements enabled is true then tell process “OmniFocus” keystroke “e” — Starts editing the current row keystroke “a” using command down — Command-A selects the text end tell end if end tell end tell end tell

Geek Phase IV – The Big Workflow

Crazy and excessive as this all may sound, this is actually one of those “life hacks” that will save me time and headache on a daily basis. It’s also a great reminder that it’s not about one application, but one workflow. The process involves triggering a snippet in TextExpander, which triggers a rule in Hazel, which creates a note with my file in Evernote, which adds a task with a link to my note in OmniFocus, but to me it’s all one fairly seamless step (there is a bit of lag, as the note synchronizes). It’s amazing what the right apps can accomplish (especially when you know the right nerds).

Thanks to Ken and Katie for the head start as well as Brett, Nick and Justin for putting up with me on this.

14 Responses to Sending Files to Evernote While Creating Tasks in OmniFocus

  1. Michael,

    and what would you propose if some of your text notes should be published and distributed to customers… I am thinking for example in meeting notes taken in plain markdown and then published directly for a customer (something like Google Docs, or even a blog?)

    Thanks in advance

  2. Hi Michael, thanks for connecting the dots!!!

    But now let’s take it one step further – how about (and let’s be clear – i am only daydreaming here) having a workflow where you forward an email with attachment to omnifocus syncing service (so far so good), the task is synced to your mac and then… If the task’s name contains a key phrase, the script takes the attachment, puts it in evenote, gets note link and replaces the original attachment in OF with the corrdsponding link.

    Actually this should be a native OF functionality – upload all attachments which are bigger than X to evernote…

    • That is a nice idea! The problem comes with how various people approach their own. They’d not only have to make this work with Evernote, but think it through for dropbox users and other products like Yojimbo.

      I wonder if you could create that using Evernote’s email and a Hazel rule…

  3. [...] in the trash with no additional effort on my part. With a minor tweak to the name, I can even create a task from the new note in Evernote. Can I do this manually? Of course, but Hazel ensures that everything is properly filed. It also [...]

  4. This is brilliant. However, I’ve found that it doesn’t run very well for me when it’s set up as a rule in Hazel. I can make it run just fine in Applescript (assuming that I use “set theFile to choose file” to make the setFile work correctly. In Applescript it runs perfectly. In Hazel it doesn’t sync nor does it bring up Omnifocus.

  5. Hi Mike, if I can get this to work I’ll be the happiest guy! I’m going to be using it to help keep my Reference PDF’s uploaded in Adobe Reader’s cloud so I can annotate them for my collection.

    I’ve run into a problem right off the bat, and my AppleScript knowledge is zero so I don’t know how to fix it. The error I’m getting is

    error “The variable theFile is not defined.” number -2753 from “theFile”

    Am I missing something in the script?

    • Hey Jamie, from what I understand (and I’m AppleScript challenged) theFile is a determination that Evernote recognizes, which is why this works. If you’re using a different application as the home for your files, you’d just need to find the proper terminology. Often times, I just seek out those who use it and use Applescript and ask.

  6. Hi Michael, this is THE best script ever! Just what I need! Is there any way to adapt it to OF2? Currently your script gives out an error at the “leaf” section of the script and I cannot find why it should error out. Best, Nick

Leave a reply