Question

So I have a Hazel rule that says "If I see a statement from this company, do X" in this case I want X to do the following.

  1. Open Evernote
  2. Check to see if I have a note with the same title as the downloaded file's title.
  3. If no, create a note from that file. If yes, do nothing.

So what I wrote so far is.

global fileNamez
tell application "Finder"
    set fileNamez to name of theFile
    tell application "Evernote"
        activate
        delay (3)
        set searchString to "\"" & fileNamez & "\""
        set matches to find notes searchString
        if (not (matches exists)) then
            display dialog "no matches"
            create note title fileNamez from file theFile
        end if
    end tell
end tell

The problem is the searching, it does not work, and I don't know whats wrong with it. Anyone have any ideas?

Was it helpful?

Solution

Try:

tell application "Finder" to set fileNamez to name of theFile

if application "Evernote" is not running then
    launch application "Evernote"
    delay 3
end if

tell application "Evernote" to set matches to find notes fileNamez
if matches = {} then
    tell application "Evernote" to set resultNote to create note from file theFile title fileNamez
    tell application "SystemUIServer" to display dialog "no matches" buttons {"OK"}
end if
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top