Permalink
Browse files

Fixed error where app would crash if note name contained ":" char

  • Loading branch information...
1 parent b00a760 commit c368c8d5194a5fc88f462704017a99d8eaf51eed @robertgaal committed Aug 26, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 notesExport.applescript
View
@@ -5,13 +5,23 @@ on writeToFile(filename, filecontents)
close access the output
end writeToFile
+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 ""
+ return this_text
+end replace_chars
+
tell application "Notes"
activate
display dialog "This is the export utility for Notes.app.\n\n" & "Exactly " & (count of notes) & " notes are stored in the application. " & "Each one of them will be exported as a simple HTML file stored in a folder of your choice." with title "Notes Export" buttons {"Cancel", "Proceed"} cancel button "Cancel" default button "Proceed"
set exportFolder to choose folder
repeat with each in every note
set noteName to name of each
set noteBody to body of each
+ set noteName to my replace_chars(noteName, ":", "-")
set filename to ((exportFolder as string) & noteName & ".html")
my writeToFile(filename, noteBody as text)
end repeat

0 comments on commit c368c8d

Please sign in to comment.