Evernote and AppleScript

I’ve been taking a look to Evernote’s dictionary.
Just curiosity.
The next snippet rises err -10002 -> an invalid key form was specified (errAEBadKeyForm)

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application id "com.evernote.Evernote" -- Evernote.app
	tell its notebook "Primera Libreta"
		tell its note "Sin título"
			creation date
		end tell
	end tell
end tell

I can’t access to any property of a note. Same error.
Any suggestions?
Thanks in advance.

I don’t have Evernote here, but on referencing collection items by name, have you tried forms like:

notebook named "Primera Libreta"
note named "Sin título"

Thanks @ComplexPoint.
Same error: Err -10002.

tell application id "com.evernote.Evernote" -- Evernote.app
	tell its notebook named "Primera Libreta"
		tell its note named "Sin título"
			creation date
		end tell
	end tell
end tell

@JMichaelTX, I know you are a heavy Evernote user.
¿Does Evernote support full AppleScript for the Basic Account?

In the script Jim posted here, notes are created with titles rather than names. If that’s what they have, the syntax will probably be something like:

tell its first note whose title is "Sin título"
1 Like

Yes. The only limits are note size and monthly upload allowance.

@NigelGarvey has already given you the fix to your problem, but here’s a couple of scripts that might help:

Get Evernote Note by Title

--- CHANGE THESE AS NEEDED ---
set nTitleToGet to "#~Note Title To Get~#"
set nbNameToGet to "#~Notebook to Get~#"


tell application "Evernote"
  
  set oNote to first note in notebook nbNameToGet whose title is nTitleToGet
  
  tell oNote
    set noteTitle to title
    set noteCDate to creation date
    set noteMDate to modification date
    set noteClassicLink to note link
  end tell
  
  set noteTagList to my getTagList(oNote)
  
end tell


on getTagList(poNote)
  
  tell application "Evernote"
    
    set tagNameList to {}
    set tagList to tags of poNote -- get list of tag objects
    
    repeat with oTag in tagList
      set tagName to name of oTag
      set end of tagNameList to tagName -- append tag name to end of list
    end repeat
    
    return tagNameList
    
  end tell -- Evernote
  
end getTagList

I rarely have a need for the above. Usually I need to use the current selection in Evernote, or search for Notes.

Get Note Currently Selected OR by Search

tell application "Evernote"
  set noteList to selection
  
  ### OR ###
  #  set noteList to (find notes "notebook:#~Notebook to Get~#") -- Same as Search Box in UI
  
  set oNote to item 1 of noteList
  
  tell oNote
    set noteTitle to title
    set noteCDate to creation date
    set noteMDate to modification date
    set noteClassicLink to note link
    set nbName to name of notebook of oNote # shouldn't need "of oNote", but you do
  end tell
end tell -- Evernote

set tagNameList to my getTagList(oNote)

set noteCDateISO to text 1 thru 10 of (noteCDate as «class isot» as string)
set noteMDateISO to text 1 thru 10 of (noteMDate as «class isot» as string)

### ADD Whatever Processing of the Note You Wish Here ###

return noteTitle

--~~~~~~~~~~~ END OF MAIN SCRIPT ~~~~~~~~~~~~~~

on getTagList(poNote)
  
  tell application "Evernote"
    
    set tagNameList to {}
    set tagList to tags of poNote -- get list of tag objects
    
    repeat with oTag in tagList
      set tagName to name of oTag
      set end of tagNameList to tagName -- append tag name to end of list
    end repeat
    
    return tagNameList
    
  end tell -- Evernote
  
end getTagList

For more of my scripts, see:
JMichaelTX GitHub Gists Using AppleScript

1 Like

Just to make point about how great SD7 is in display an app’s dictionary (SDEF), here’s a screenshot from Script Debugger 7 7.0.1 (7A48) on macOS 10.12.6:

Thanks @JMichaelTX.
Very clear.
Didn’t know your GitHub.