Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
This AppleScript script will scan Evernote for notes by several different conditions (all notes in inbox, all notes tagged "!", all notes with an incomplete reminder) and, if they are not already tagged as having been processed ("task" tag) then task is added into OmniFocus with evernote native URL attached to the task so that you will be able t…
(*
This script scans Evernote for notes, in a variety of ways, and adds references to them into OmniFocus
as inbox items. The point is to remove the necessity of reviewing your notes in Evernote to determine
if action needs to be taken by manually looking for the same sorts of things in Evernote yourself.
A typical use case scenario would be:
1. You are browsing the web and you see an article you are interested in reading later
2. You use Evernote Webclipper to save the article, perhaps simplified for reading.
3. The script eventually runs via Cron job or otherwise and adds a task to OmniFocus
4. When you do your regular review of inbox items in OmniFocus you see the task for reading
5. You're elated that you will now remember to read the article at some point since
you had entirely forgotten that you even clipped it to begin with.
It is even more useful when notes are added to Evernote from autonomous sources such as IFTTT!
Users of tools like OmniFocus understand the value of reducing the amount of manual combing for
incoming tasks. The fewer "inboxes" you have, the better. This script merges a variety of
"inboxes" that may exists, virtually, in Evernote into your OmniFocus Inbox automatically.
The basic idea is that each evaluation block finds notes in a different way. If it finds any
notes that lack the "task" tag, it will add a task to OmniFocus with an evernote:// link in
the task's own note field then mark the evernote note with the task tag so it will be ignored
in future scans.
The types of searches performed are:
1. All notes in the default notebook (specified in the inboxNotebook variable)
2. All notes with the force import tag (specified below) which defaults to "!"
3. All notes with a reminder but no due date that has not been marked as finished
4. Same as #3 except if the reminder has a due date, that will be added in OmniFocus as well
*)
tell application "Evernote"
set inboxNotebook to "All Incoming"
set importedTagName to "task"
set forceImportTagName to "!"
set importedTag to tag importedTagName
synchronize
repeat while isSynchronizing
delay (2)
end repeat
set unprocessedNotes to notes in notebook inboxNotebook
repeat with currentNote in unprocessedNotes
set inboxThisNote to true
set currentTags to tags of currentNote
repeat with currentTag in currentTags
set currentTagName to (the name of currentTag as text)
if currentTagName is equal to importedTagName then
set inboxThisNote to false
end if
end repeat
if inboxThisNote then
set noteTitle to title of currentNote
set noteLink to note link of currentNote
tell application "OmniFocus"
tell default document
make new inbox task with properties {name:noteTitle, note:noteLink}
end tell
end tell
assign importedTag to currentNote
end if
end repeat
set unprocessedNotes to find notes "tag:\"" & forceImportTagName & "\" -tag:\"" & importedTagName & "\""
repeat with currentNote in unprocessedNotes
set noteTitle to title of currentNote
set noteLink to note link of currentNote
tell application "OmniFocus"
tell default document
make new inbox task with properties {name:noteTitle, note:noteLink}
end tell
end tell
assign importedTag to currentNote
end repeat
set unprocessedNotes to find notes "reminderOrder:* -reminderDoneTime:* -reminderTime:* -tag:\"" & importedTagName & "\""
repeat with currentNote in unprocessedNotes
set noteTitle to title of currentNote
set noteLink to note link of currentNote
tell application "OmniFocus"
tell default document
make new inbox task with properties {name:noteTitle, note:noteLink}
end tell
end tell
assign importedTag to currentNote
end repeat
set unprocessedNotes to find notes "reminderOrder:* -reminderDoneTime:* reminderTime:* -tag:\"" & importedTagName & "\""
repeat with currentNote in unprocessedNotes
set noteTitle to title of currentNote
set noteLink to note link of currentNote
set noteTime to reminder time of currentNote
tell application "OmniFocus"
tell default document
make new inbox task with properties {name:noteTitle, note:noteLink, due date:noteTime}
end tell
end tell
assign importedTag to currentNote
end repeat
tell application "OmniFocus"
synchronize
end tell
synchronize
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment