Skip to content

Instantly share code, notes, and snippets.

@ZhuYouwei
Last active August 14, 2021 12:50
Show Gist options
  • Save ZhuYouwei/3d828f3ef2cd4f158af7e8fef8c17313 to your computer and use it in GitHub Desktop.
Save ZhuYouwei/3d828f3ef2cd4f158af7e8fef8c17313 to your computer and use it in GitHub Desktop.
Export Mac Notes to txt file
property outputPath : (path to desktop as text) & "export"
tell application "Finder"
if not (exists outputPath) then
make new folder at desktop with properties {name:"export"}
end if
end tell
tell application "Notes"
set Nf to text returned of (display dialog "Folder Name" default answer "Notes")
if not (exists folder Nf in account "iCloud") then
display dialog "No such Folder"
error number -128
end if
repeat with aNote in notes in folder Nf in account "iCloud"
set Ntitle to name of aNote
set NContent to plaintext of aNote
tell application "TextEdit"
set thisDoc to make new document with properties {name:(Ntitle & ".txt"), text:NContent}
close thisDoc saving in POSIX file (POSIX path of (outputPath) & "/" & (name of thisDoc))
end tell
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment