#!/usr/bin/osascript on run argv if (count of argv) < 2 then return "Usage: add_note.scpt <body>" end if set noteTitle to item 1 of argv set noteBody to item 2 of argv -- Apple Notes expects HTML for the body. -- We'll wrap the body in minimal HTML. set htmlBody to "<div>" & noteBody & "</div>" -- Replace newlines with <br> set htmlBody to do shell script "echo " & quoted form of htmlBody & " | sed 's/$/<br>/'" tell application "Notes" tell default account -- Check if note exists to append, or create new set existingNotes to (notes whose name is noteTitle) if (count of existingNotes) > 0 then set currentNote to item 1 of existingNotes set currentBody to body of currentNote -- Append to existing body set body of currentNote to currentBody & "<br>" & htmlBody return "Appended to note: " & noteTitle else make new note with properties {name:noteTitle, body:htmlBody} return "Created new note: " & noteTitle end if end tell end tell end run