Skip to content

Instantly share code, notes, and snippets.

@kazazes
Created December 26, 2020 07:33
Show Gist options
  • Save kazazes/979735abfe1363a24991b2a85a5e8b08 to your computer and use it in GitHub Desktop.
Save kazazes/979735abfe1363a24991b2a85a5e8b08 to your computer and use it in GitHub Desktop.
// 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