#!/usr/bin/osascript on run argv set searchObj to "" if (count of argv) > 0 then set searchObj to item 1 of argv end if tell application "Notes" if searchObj is "" then set foundNotes to notes of default account -- limiting to top 10 recent set noteCount to count of foundNotes if noteCount > 10 then set noteCount to 10 set subNotes to items 1 thru noteCount of foundNotes else set subNotes to (notes of default account whose name contains searchObj) end if set output to "" repeat with aNote in subNotes set nName to name of aNote set nBody to body of aNote -- This is HTML set nModDate to modification date of aNote -- Simple HTML cleanup for readability (very basic) set nBodyClean to do shell script "echo " & quoted form of nBody & " | sed -e 's/<[^>]*>//g'" set output to output & "Note: " & nName & "\nModified: " & nModDate & "\nBody: " & nBodyClean & "\n---\n" end repeat return output end tell end run