1

I've been using this little utility to save out random thoughts through the day to a text file. I want to append the user input to an existing note in the notes APP, but can't figure out getting beyond simply calling the notes app. Any help would be greatly appreciated! Extra credit: If anyone has experience using Applescript to send data to a Google Sheet, I'd appreciate any resources - I have had a tough time finding any.

Thanks!

Here is my working script that logs user input to a text file.

set f to "/Users/Weston/Desktop/JAT.txt"
set myDate to date string of (current date)
set myTime to time string of (current date)
set myStamp to myDate & " " & myTime


set JAT to text returned of (display dialog "What's on your mind, Weston?" default answer " " with icon note buttons {"Cancel", "Continue"} default button "Continue")

set entry to return & ">" & myStamp & " | " & JAT

set myFile to open for access f with write permission
write entry to f starting at (get eof of f) + 1
close access myFile

quit
3
  • When you say you can't get beyond simply calling the Notes app you mean in Applescript I assume? – Natsfan Jun 18 '20 at 0:34
  • Yes, sorry I wasn't more clear! – WheninSeattle Jun 18 '20 at 1:00
  • you were fine. i just misunderstood. – Natsfan Jun 18 '20 at 1:15
1

This question explains how to modify text on Notes, so here's how that would be implemented in your code:

set noteName to "JAT"
set myDate to date string of (current date)
set myTime to time string of (current date)
set myStamp to myDate & " " & myTime


set JAT to text returned of (display dialog "What's on your mind, Weston?" default answer " " with icon note buttons {"Cancel", "Continue"} default button "Continue")

set entry to return & ">" & myStamp & " | " & JAT

tell application "Notes"
    tell account "iCloud"
        set body of note noteName to (get body of note noteName & entry)
    end tell
end tell

quit

Don't forget to create the note first, though.

3
  • Thank you for your reply! This is a running list of notes throughout the day - part of my issue is appending a new entry to the existing note without overwriting the existing entires. – WheninSeattle Jun 18 '20 at 1:01
  • You're welcome. So is the problem solved? My method technically overwrites the note, but copies it beforehand and puts it back in so it shouldn't be a problem. – htmlcat Jun 18 '20 at 2:00
  • You're right - that does the trick. Thank you again for your help! – WheninSeattle Jun 18 '20 at 4:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .