Created
September 2, 2013 05:14
-
-
Save fractaledmind/6409392 to your computer and use it in GitHub Desktop.
This script creates a new Note in a selected Notebook that contains hyperlinks to all of the other notes in that notebook. Thus, it create a Notebook Index note for a chosen Notebook.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Create Notebook Index Note With Hyperlinks to All Notes in that Notebook *) | |
property LF : ASCII character 10 | |
tell application "Evernote" | |
set nbNames to name of every notebook | |
set nbNames to my simple_sort(nbNames) | |
set nbName to choose from list nbNames with title "Create Index Note for which Notebook?" | |
set nbName to nbName as string | |
set nbNotes_titles to title of every note of notebook nbName | |
set nbNotes_links to note link of every note of notebook nbName | |
set nbNotes_markdown to "" | |
repeat with i from 1 to count of nbNotes_titles | |
set theTitle to item i of nbNotes_titles | |
set theLink to item i of nbNotes_links | |
set wikiLink to "<p><a href=\"" & theLink & "\">" & theTitle & "</a></p>" & LF & LF | |
set nbNotes_markdown to nbNotes_markdown & wikiLink | |
end repeat | |
set newNote to create note title "! " & nbName & " Index" with html nbNotes_markdown notebook nbName | |
end tell | |
(* HANDLERS *) | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment