Last active
September 16, 2019 18:22
-
-
Save troutcolor/8601aa11b9969e5d289948c693d29c32 to your computer and use it in GitHub Desktop.
Export a folder to html with page breaks for printing. Used https://gist.github.com/able8/0a7ac85ebb3f77b7b427288621551b86 as a starter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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