|
(* |
|
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 |