Skip to content

Instantly share code, notes, and snippets.

@gurdiga
Created July 23, 2019 01:40
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 gurdiga/99c5c17cb6d5a1ceb2295cd4fa81f773 to your computer and use it in GitHub Desktop.
Save gurdiga/99c5c17cb6d5a1ceb2295cd4fa81f773 to your computer and use it in GitHub Desktop.
Export Apple Notes to plain text
tell application "Notes"
repeat with eachNote in notes in folder "Log"
tell eachNote
set content to body as text
set {year:y, month:m, day:d, hours:h, minutes:n} to creation date
set m to m as number
set d to d as number
set n to n as number
set h to h as number
if (m < 10) then
set m to "0" & m
end if
if (d < 10) then
set d to "0" & d
end if
if (h < 10) then
set h to "0" & h
end if
if (n < 10) then
set n to "0" & n
end if
set fileName to (y as string) & "-" & m & "-" & d & "-" & h & "-" & n
if (fileName = "Friday writing") or (fileName = "Thursday writing") or (fileName = "Life review") or (fileName = "Monthly review") or (fileName = "Weekly review") or (fileName = "Thinking session") or (fileName = "Thinking") then
set content to "<h1>" & fileName & "</h1>" & content
end if
set quotedContent to quoted form of content
do shell script "echo " & quotedContent & " | /usr/local/bin/pandoc --from=html --to=plain --wrap=none > /Users/vlad/tmp/notes/'" & fileName & ".md'"
end tell
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment