Created
December 26, 2020 07:33
-
-
Save kazazes/979735abfe1363a24991b2a85a5e8b08 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 things up | |
var app = Application.currentApplication(); | |
app.includeStandardAdditions = true; | |
var notesApp = Application('Notes'); | |
notesApp.includeStandardAdditions = true; | |
// choose which notes | |
var notes = notesApp.notes; | |
var whichNotes = app.chooseFromList(notes.name(), { withPrompt: "Which Notes?", multipleSelectionsAllowed: true }); | |
if (whichNotes) { | |
// choose save location | |
var saveWhere = app.chooseFolder().toString(); | |
if (saveWhere) { | |
// loop through all notes | |
for(var i=0; i<notes.length; i++) { | |
// is this note one to be exported? | |
if (whichNotes.indexOf(notes[i].name()) > -1) { | |
// save file as html | |
var filename = saveWhere+"/"+notes[i].name()+".html"; | |
var file = app.openForAccess(Path(filename), { writePermission: true }); | |
app.setEof(file, { to: 0 }); | |
app.write(notes[i].body(), {to: file}); | |
app.closeAccess(file); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment