Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Export a folder to html with page breaks for printing. Used https://gist.github.com/able8/0a7ac85ebb3f77b7b427288621551b86 as a starter.
set htmltop to "<!doctype html>
<html lang=\"en\">
<head>
<meta charset=\"utf-8\">
<title>Notes Export</title>
<style>
@media print {
hr {
page-break-after: always;
}
}
</style>
</head>
<body>"
set htmlbottom to "</body>
</html>"
tell application "Notes"
activate
set x to (name of every folder whose name is not "Notes")
set foldertoexport to (choose from list x) as string
if folder foldertoexport exists then
set output to ""
repeat with aNote in notes in folder foldertoexport
set noteText to "<!-- ### Start Note ### -->
"
set noteText to noteText & ("<h1>" & name of aNote as string) & "</h1>
"
-- set noteText to noteText & ("<p>Creation Date: " & creation date of aNote as string) & "</p>"
-- set noteText to noteText & ("<p>Modification Date: " & modification date of aNote as string) & "</p>"
set noteText to (noteText & body of aNote as string) & "<hr>
"
set output to output & noteText
end repeat
set thehtml to htmltop & output & htmlbottom
set theNewFile to choose file name default name foldertoexport & "-notes.html"
set myFile to open for access theNewFile with write permission
write thehtml to myFile as «class utf8»
close access myFile
else
display dialog "not likly to happen"
end if
end tell
tell application "Finder" to open theNewFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment