Skip to content

Instantly share code, notes, and snippets.

@mmansion
Created April 23, 2017 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmansion/dad526f5c9c59bf13e8016e070936f05 to your computer and use it in GitHub Desktop.
Save mmansion/dad526f5c9c59bf13e8016e070936f05 to your computer and use it in GitHub Desktop.
Evernote - Searching Notebooks & Notes
(*
[APPLESCRIPT FOR EVERNOTE]
EXAMPLE FOR SEARCHING FOR NOTEBOOKS & NOTES
* by mmansion
* last updated 2017.04.23
*)
----------------------------------------
-- SETUP
set noteTitleToFind to "[template] - Daily Logs"
set noteBookToFind to "_Templates"
set foundNoteBook to false
set foundNote to false
----------------------------------------
-- MAIN SCRIPT
tell application "Evernote"
-- 1. determine if notebook exists, anywhere in evernote
set foundNoteBook to (notebook named noteBookToFind exists)
display dialog "Found " & noteBookToFind & " = " & foundNoteBook
-- 2. determine if a specific note exists, anywhere in evernote
set globalNoteList to find notes ("intitle:\"" & noteTitleToFind & "\"")
set numGlobalNotesFound to count of globalNoteList
-- have we found at least one note by this title in Evernote?
-- there may be multiple notes of the same title
set foundNote to (numGlobalNotesFound ≥ 1)
display dialog "Found note titled \"" & noteTitleToFind & "\" in Evernote = " & foundNote
-- 3. determine if a specific note exists, but within a specific notebook:
set noteList to find notes "notebook:\"" & noteBookToFind & "\" intitle:\"" & noteTitleToFind & "\""
-- multiple notes with this title within the notebook?
set numNotes to count of noteList
-- log the number of notes found in the notebook:
display dialog "Number of notes by the title " & noteTitleToFind & " found inside " & noteBookToFind & " = " & numNotes
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment