Description
Originally posted on CAPH Tech (Note: Website is Japanese / 日本語), this script will copy a link to the currently selected task/project/folder in OmniFocus to a new note item in Evernote. If the item is a part of a OmniFocus Project, the script will add the Project name as a tag -- creating one if none currently exists!The Code
tell front window of application "OmniFocus"
try
set theTrees to selected trees of content
if (count of theTrees) < 1 then
set theTrees to selected trees of sidebar
end if
if (count of theTrees) < 1 then
return
end if
set theSelection to value of item 1 of theTrees
if class of theSelection is folder then
set theURI to "omnifocus:///folder/" & id of theSelection
set theNote to ""
else if class of theSelection is project then
set theURI to "omnifocus:///project/" & id of theSelection
set theNote to ""
else
set theURI to "omnifocus:///task/" & id of theSelection
set theNote to note of theSelection
set theProjectName to name of containing project of theSelection
end if
set theName to name of theSelection
tell application "Evernote"
set newNote to create note with text theURI & return & theNote
set title of newNote to theName
set source URL of newNote to theURI
if (count of theProjectName) > 0 then
if (not (tag named theProjectName exists)) then
make tag with properties {name:theProjectName}
end if
set theTag to tag named theProjectName
assign theTag to newNote
end if
open note window with newNote
activate
end tell
end try
end tell
try
set theTrees to selected trees of content
if (count of theTrees) < 1 then
set theTrees to selected trees of sidebar
end if
if (count of theTrees) < 1 then
return
end if
set theSelection to value of item 1 of theTrees
if class of theSelection is folder then
set theURI to "omnifocus:///folder/" & id of theSelection
set theNote to ""
else if class of theSelection is project then
set theURI to "omnifocus:///project/" & id of theSelection
set theNote to ""
else
set theURI to "omnifocus:///task/" & id of theSelection
set theNote to note of theSelection
set theProjectName to name of containing project of theSelection
end if
set theName to name of theSelection
tell application "Evernote"
set newNote to create note with text theURI & return & theNote
set title of newNote to theName
set source URL of newNote to theURI
if (count of theProjectName) > 0 then
if (not (tag named theProjectName exists)) then
make tag with properties {name:theProjectName}
end if
set theTag to tag named theProjectName
assign theTag to newNote
end if
open note window with newNote
activate
end tell
end try
end tell
This is a great script and works well. One thing it doesn’t do is leave a live link back to Omnifocus from Evernote. The link is there — in the Evernote note — but the link isn’t active. Is there any way to make it link back to Omnifocus?
thanks