Search Evernote for Notes Containing Link To Selected OmniFocus Item

Description

Originally posted on CAPH Tech (Note: Website is Japanese / 日本語), this script will search through your Evernote note collection for a link to the currently selected task/project/folder in OmniFocus. Once the items are found, the script will display the results of the search in a separate Note Collection window.

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
        else if class of theSelection is project then
            set theURI to "omnifocus:///project/" & id of theSelection
        else
            set theURI to "omnifocus:///task/" & id of theSelection
        end if
 
        tell application "Evernote"
            open collection window with query string theURI
            activate
        end tell
    end try
end tell

4 Responses to “Search Evernote for Notes Containing Link To Selected OmniFocus Item”

  1. Jimmy September 28, 2013 at 3:03 pm #

    Hey r.izumita,
    Nice script! I’m wondering how I could make this script a little better for my needs. Maybe you can help…

    I’m wanting the search script search for the folder or project like normal, but if it is searching for a task then make it search for the task with the containing project tag. So, I’m trying to figure out how to add in the containing projects name as a tag query after the original search string.

    Example: If I try to search for the project and it has a note for the project, it will work fine. but if I forget the note is for the project not a specific task within the project and I search with a task selected it will tell me there is no note for the task. So, I need a search function that will get me all project notes if I select a note. And this is only if I am searching for a task.

    Any pointers on how to do this?

    • Jimmy September 29, 2013 at 3:45 am #

      Nevermind, I think I figured out a working solution. Check it out .

    • Jimmy September 29, 2013 at 3:46 am #

      Oops. That link title didn’t work like I hoped. Here it is: https://github.com/masterninja01/OF-to-EV-Search

      • Nick June 20, 2014 at 2:40 pm #

        Not sure I get this one. What exactly is the script trying to do and how did you improve Jimmy?