indexing Evernote notes with LaunchBar finally solved
Posted: Sun Feb 19, 2012 3:34 am
The Evernote mothership updated the AppleScript dictionary, and you can now grab the note link. This means that it’s now quite trivial to go through a selection of notes, getting the note link and making a .webloc file out of each one. LaunchBar can index … boom. Pretty easy.
Code: Select all
tell application "Evernote"
set noteList to selection
repeat with currentEvernote in noteList
set noteTitle to title of currentEvernote -- the noteTitle will also be the filename
set noteURL to note link of currentEvernote
-- you may want to replace other characters in titles! colons are particularly important to replace, because they will break the POSIX path if you don’t
set noteTitle to my replace_chars(noteTitle, ":", " - ")
set weblocXML to "\"<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'><plist version='1.0'><dict><key>URL</key><string>" & noteURL & "</string></dict></plist>\""
set filepath to "path:to:wherever:you:wanna:put:them" & noteTitle & ".webloc"
set shell_script to "echo > " & the quoted form of the POSIX path of filepath & " " & weblocXML
do shell script shell_script with administrator privileges
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""