Find all single-note tags in Evernote

January 14, 2015
I’ve been working on cleaning up my Evernote, and noticed that I have a lot of tags assigned to a single note. I had successfully used Veritrope’s excellent Evernote empty tag remover applescript, so I made some small changes to write the attached script, which will find all single-note tags in your Evernote and list them in a new note, including links to each note. This makes it much easier to go through them and see which of those tags could be removed.

Just download the script, open it in Script Editor and run it.

Tip of the hat to Justin for his excellent collection of scripts at Veritrope!

(*
Evernote -- Find all single-note tags
January 13, 2015, Diego Zamboni
http://zzamboni.postach.io/find-all-single-note-tags-in-evernote
Based on:
http://veritrope.com
Evernote -- Empty Tag Remover
http://veritrope.com/code/evernote-empty-tag-remover
*)
set output to {}
tell application "Evernote"
try
set theTags to every tag
repeat with theTag in theTags
set theNotes to {}
set theName to "\"" & name of theTag & "\""
set theNotes to (find notes "tag:" & theName)
if (count of theNotes) is 1 then
copy ((name of theTag) & ": " & "<a href='" & (note link of (first item of theNotes)) & "'>" & (title of (first item of theNotes)) & "</a>") to the end of output
end if
end repeat
end try
set sortedTags to my simple_sort(output)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "<br>"
set articleList to sortedTags as text
set AppleScript's text item delimiters to oldDelim
set o to create note with html articleList title "Single-note tags"
open note window with o
end tell
--SORT SUBROUTINE
on simple_sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end simple_sort

Airmail tip: prevent "Save to Evernote" action from opening the created note

March 6, 2014
I’ve been trying out Airmail as my main email app. It’s quite nice, I like the built-in integrations, particularly with Evernote. By default, when you use the “Save to Evernote” action, it saves the current message to Evernote and opens the newly-created note. I went spelunking into the Airmail application directory, and found the way to disable the note-opening. Follow these steps:
  1. Quit Airmail (don’t know if this is necessary, but it can’t hurt)
  2. Open the Terminal app
  3. Run the following command in the terminal (all in a single line):
    sudo /Applications/Utilities/AppleScript\ Editor.app/Contents/MacOS/AppleScript\ Editor  /Applications/Airmail.app/Contents/Resources/Evernote.applescript
    This will ask you for your password and then run the AppleScript Editor.
    Note: in my experience, the AppleScript Editor app may open behind the terminal window - look at the Dock for its icon, and bring it to the front.
  4. In the AppleScript Editor window, find this line:
                open note window with the note
    and comment it out by inserting a # at the beginning, like this:
    #            open note window with the note
  5. Save the modified file and quit AppleScript Editor.
  6. Restart Airmail.
That’s it! Now the “Save to Evernote” action saves the current message to Evernote, but does not open it.