taskbridgeapp.notes.model.notescript.get_notes_script
- taskbridgeapp.notes.model.notescript.get_notes_script = 'on run argv\nset folder_name to item 1 of argv\ntell application "Finder"\n set save_location to (POSIX path of (path to temporary items folder) as text) & "taskbridge/notesync/" & folder_name\n do shell script "mkdir -p " & quoted form of save_location\nend tell\ntell application "Notes"\n set myFolder to first folder whose name = folder_name\n set myNotes to notes of myFolder\n repeat with theNote in myNotes\n set nId to id of theNote\n set nName to name of theNote\n set nBody to body of theNote\n set nCreation to creation date of theNote\n set nModified to modification date of theNote\n set attachmentList to "~~START_ATTACHMENTS~~\n"\n repeat with theAttachment in attachments of theNote\n set attachmentList to attachmentList & name of theAttachment & "~~" & url of theAttachment & "\n"\n end repeat\n set attachmentList to attachmentList & "~~END_ATTACHMENTS~~"\n set stagedContent to nId & "~~" & nName & "~~" & nCreation & "~~" & nModified\n set stagedContent to stagedContent & "\n" & attachmentList & "\n" & nBody\n tell application "Finder"\n set aPath to "taskbridge:notesync:" & folder_name & ":" & nName & ".staged"\n set accessRef to (open for access file ((path to temporary items folder as text) & aPath) with write permission)\n try\n set eof accessRef to 0\n write stagedContent to accessRef as «class utf8»\n close access accessRef\n on error errMsg\n close access accessRef\n log errMsg\n end try\n end tell\n end repeat\nend tell\nreturn save_location\nend run'
Get the list of notes from a folder and export as a staged file.