Skip to content

Instantly share code, notes, and snippets.

@tkalus
Created August 1, 2019 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkalus/3d2eb50c2eb0b841ce45c3a4c7337c3c to your computer and use it in GitHub Desktop.
Save tkalus/3d2eb50c2eb0b841ce45c3a4c7337c3c to your computer and use it in GitHub Desktop.
Export an entire Folder in Apple Notes to a single text file via TextEdit
tell application "TextEdit"
activate
make new document
end tell
tell application "Notes"
if folder "Stuff" exists then
set output to ""
repeat with aNote in notes in folder "Stuff"
set rawText to "----------\n"
set rawText to rawText & (name of aNote as string) & "\n"
set rawText to rawText & "----------\n"
set rawText to rawText & (name of aNote as string) & "\n"
set rawText to rawText & (body of aNote as string) & "\n\n"
set inTag to false
set scrubbedText to ""
repeat with i from 1 to length of rawText
set rawChar to character i of rawText
if rawChar is "<" then
set inTag to true
else if rawChar is ">" then
set inTag to false
else if inTag is false then
set scrubbedText to scrubbedText & rawChar as string
end if
end repeat
tell application "TextEdit"
activate
set oldText to text of document 1
set text of document 1 to oldText & scrubbedText
end tell
end repeat
else
display dialog "Nope. No folder..."
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment