Evernote — Create Note and Get Note Link
Description
Michael Schechter recently asked if I knew of a way to get Note Links in Evernote for newly-created Notes.
Seemed like it should be easy to do with AppleScript, given that Evernote created a “note link” definition for people like Michael to play with but, when you’d try to use it on a newly created item, AppleScript would return a very frustrating missing value where the link should be.
After a little trial and error, I found that using some special types of repeat loops seemed to do the trick. The code below is a sample to give interested scripters an idea of how to use it in their own projects.
The basic concept is this: Our script checks with Evernote to see if the app is currently synching its data with (using the isSynchronizing action) and, if so, pauses until it’s finished. It then creates our new note and tells Evernote to synchronize. This begins the process of refreshing the note’s information and making the link available to AppleScript. While this is happening, AppleScript keeps checking with Evernote to see if the link is available yet. Once it is, it writes it to a variable.
The Code
set myNote to {}
set noteLink to missing value
tell application "Evernote"
--TEST TO SEE IF EVERNOTE IS CURRENTLY SYNCHRONIZING...
repeat until isSynchronizing is false
--THIS EMPTY LOOP WILL PAUSE SCRIPT UNTIL PREVIOUS SYNC IS FINISHED
end repeat
--CREATE THE NOTE
set myNote to create note with text "HI!"
--SYNCHRONIZE WITH EVERNOTE'S SERVERS
synchronize
--PAUSE UNTIL THERE IS A VALUE FOR NOTE LINK
repeat while noteLink is missing value
--GET THE NOTE LINK FOR THE CURRENT NOTE
set noteLink to (note link of myNote)
end repeat
end tell
Quick Links
Click here to open it in your Script Editor
Save this into Snippets
New To AppleScript?
- Here's how to use the AppleScripts you find here and -- to make them even easier to use -- here's how run them with simple keyboard shortcuts!
- Be sure to check out other great AppleScripts in the Veritrope.com Code Library -- and share your own AppleScript projects using the quick submission form!





No Comments / Add Yours!