Reminders.app

Has anyone scripted Mountain Lion’s Reminders app yet?

I’m trying to make an automated system to create a series of reminders from input text, and possibly an email, if it works.

K@

Scripting Reminder is pretty much the same then scripting iCal Todos.

As a starter…


tell application "Reminders"
	make new list with properties {name:"Test"}
	set mylist to list "Test"
	tell mylist
		make new reminder with properties {name:"Test Reminder", body:"New Reminder"}
	end tell
end tell

1 Like

Thanks sroeper, that worked a treat.

I was expecting it to be more obscure!

hello,

what I don’t understand is how to go from a text line:

tomorrow at ten call Bob, about his new book

where the first part is the name of the reminder
where the second part is the body of the reminder

to the actual reminder…

how does it work
make new reminder with properties {name:“Test Reminder”, body:“New Reminder”} ??

how do I get them from a text line as the one shown above?

TIA

sorry for the dummy question

please help

amelchi@gmail.com

Not a dummy question.

I hope that you will get every wanted infos in the script below :

tell application "Reminders"
	set theLists to get every list
	repeat with aList in theLists
		properties of aList
	end repeat
	set theNames to name of every list
	repeat with aList in theLists
		reminders of aList
	end repeat
	set theReminders to every reminder
	repeat with aReminder in theReminders
		tell aReminder
			due date --> missing value
			modification date --> date "samedi 4 février 2017 à 19:01:40"
			body --> "New Reminder"
			completed --> false
			creation date --> date "samedi 4 février 2017 à 19:01:40"
			name --> "Test Reminder"
			completion date --> missing value
			priority --> 0
			remind me date --> missing value
		end tell
	end repeat
	set testReminders to every reminder whose name starts with "Test"
	--> {reminder id "x-apple-reminder://AEE217B6-57CE-4882-AD00-868A5D63A28C"}
	repeat with aReminder in testReminders
		tell aReminder
			due date --> missing value
			modification date --> date "samedi 4 février 2017 à 19:01:40"
			body --> "New Reminder"
			completed --> false
			creation date --> date "samedi 4 février 2017 à 19:01:40"
			name --> "Test Reminder"
			completion date --> missing value
			priority --> 0
			remind me date --> missing value
		end tell
	end repeat
	
	if not (exists (first reminder whose name is "call Bob")) then
		tell me # Required because we can't work upon dates in the tell application "Reminders" block
			set dueDate to (date (get short date string of (current date))) + (1 * days) + (10 * hours)
		end tell
		tell list "Test"
			set newReminder to make new reminder with properties {name:"call Bob", body:" about his new book", due date:dueDate}
		end tell
	else
		set newReminder to (first reminder whose name is "call Bob")
	end if
	tell newReminder
		name --> "call Bob"
		due date --> date "dimanche 5 février 2017 à 10:00:00"
		body --> " about his new book"
	end tell
end tell

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) samedi 4 février 2017 19:38:33

Thanks Yvan, but…

the script keep running with no result…

no result or error message ?

Here, as I deleted the list “Test” after posting here, now I logically get : error “Erreur dans Reminders : Il est impossible d’obtenir list "Test".” number -1728 from list “Test”.

So, I added the instructions borrowed from message #1 of this thread :

tell application "Reminders"
	
	make new list with properties {name:"Test"}
	set mylist to list "Test"
	tell mylist
		make new reminder with properties {name:"Test Reminder", body:"New Reminder"}
	end tell
	
	set theLists to get every list
# continue

With these instructions I got what I got the events which I got yesterdays :


# DON'T OPEN THIS ONE, IT's NOT A SCRIPT, IT's THE EVENTS LOG !!

 tell application "Reminders"
	make new list with properties {name:"Test"}
		--> list id "FD27DB70-23F5-4D08-B395-4E8DFAA9D0C4"
	get list "Test"
		--> list id "FD27DB70-23F5-4D08-B395-4E8DFAA9D0C4"
	make new reminder with properties {name:"Test Reminder", body:"New Reminder"}
		--> reminder id "x-apple-reminder://hidden"
	get every list
		--> {list id "ECFE80A2-BCAA-4677-9881-51BCFB58144D", list id "FD27DB70-23F5-4D08-B395-4E8DFAA9D0C4"}
	get properties of list id "ECFE80A2-BCAA-4677-9881-51BCFB58144D"
		--> {name:"Sports", class:list, id:"ECFE80A2-BCAA-4677-9881-51BCFB58144D", container:missing value}
	get properties of list id "FD27DB70-23F5-4D08-B395-4E8DFAA9D0C4"
		--> {name:"Test", class:list, id:"FD27DB70-23F5-4D08-B395-4E8DFAA9D0C4", container:missing value}
	get name of every list
		--> {"Sports", "Test"}
	get every reminder of list id "ECFE80A2-BCAA-4677-9881-51BCFB58144D"
		--> {}
	get every reminder of list id "FD27DB70-23F5-4D08-B395-4E8DFAA9D0C4"
		--> {reminder id "x-apple-reminder://hidden"}
	get every reminder
		--> {reminder id "x-apple-reminder://hidden"}
	get due date of reminder id "x-apple-reminder://hidden"
		--> missing value
	get modification date of reminder id "x-apple-reminder://hidden"
		--> date "dimanche 5 février 2017 à 12:05:31"
	get body of reminder id "x-apple-reminder://hidden"
		--> "New Reminder"
	get completed of reminder id "x-apple-reminder://hidden"
		--> false
	get creation date of reminder id "x-apple-reminder://hidden"
		--> date "dimanche 5 février 2017 à 12:05:31"
	get name of reminder id "x-apple-reminder://hidden"
		--> "Test Reminder"
	get completion date of reminder id "x-apple-reminder://hidden"
		--> missing value
	get priority of reminder id "x-apple-reminder://hidden"
		--> 0
	get remind me date of reminder id "x-apple-reminder://hidden"
		--> missing value
	get every reminder whose name starts with "Test"
		--> {reminder id "x-apple-reminder://hidden"}
	get due date of reminder id "x-apple-reminder://hidden"
		--> missing value
	get modification date of reminder id "x-apple-reminder://hidden"
		--> date "dimanche 5 février 2017 à 12:05:31"
	get body of reminder id "x-apple-reminder://hidden"
		--> "New Reminder"
	get completed of reminder id "x-apple-reminder://hidden"
		--> false
	get creation date of reminder id "x-apple-reminder://hidden"
		--> date "dimanche 5 février 2017 à 12:05:31"
	get name of reminder id "x-apple-reminder://hidden"
		--> "Test Reminder"
	get completion date of reminder id "x-apple-reminder://hidden"
		--> missing value
	get priority of reminder id "x-apple-reminder://hidden"
		--> 0
	get remind me date of reminder id "x-apple-reminder://hidden"
		--> missing value
	exists reminder 1 whose name = "call Bob"
		--> false
end tell
tell current application
	current date
		--> date "dimanche 5 février 2017 à 12:05:31"
end tell
tell application "Reminders"
	make new reminder with properties {name:"call Bob", body:" about his new book", due date:date "lundi 6 février 2017 à 10:00:00"}
		--> reminder id "x-apple-reminder://hidden2"
	get name of reminder id "x-apple-reminder://hidden2"
		--> "call Bob"
	get due date of reminder id "x-apple-reminder://hidden2"
		--> date "lundi 6 février 2017 à 10:00:00"
	get body of reminder id "x-apple-reminder://hidden2"
		--> " about his new book"
end tell
Résultat :
" about his new book"

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) dimanche 5 février 2017 12:11:13

yes error message

expected end of line, etc. but found unknown token

Hey @amelchi,

Sometimes these unknown token errors can be as simple as a non-breaking-space.

This script has worked reliably for me for over a year now:


-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/10/26 04:49
# dMod: 2016/02/23 16:09
# Appl: Reminders, Safari
# Task: Create Reminder from front Safari page.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Reminders, @Safari, @Create, @Make
-------------------------------------------------------------------------------------------

do shell script "open -ga Reminders"

set _date to (current date) + (1 * days)
set listName to "Reminders - iCloud"

tell application "Safari"
	tell front document
		set _url to its URL
		set _name to its name
	end tell
end tell

tell application "Reminders"
	activate
	show list listName
	tell list listName
		set newReminder to make new reminder with properties {name:_name, body:_url, remind me date:_date}
		show newReminder
	end tell
end tell


Chris
··················································································
{ MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.12.3 }

Which OS version are you running ? Here it’s 10.12.3.
Which version of Reminders are you using ? Here it’s version 4.0 (441.9)

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) dimanche 5 février 2017 18:02:17

@ChristopherStone

Hello
When I executed the script which is in my first message this morning, I got the message :
error “Erreur dans Reminders : Il est impossible d’obtenir list "Test".” number -1728 from list “Test”

because yesterdays I removed the list which I didn’t need.

When I added the lines listed in my second message, everything behaved well.

No way to get : expected end of line, etc. but found unknown token

The format used in the asker’s question :
“tomorrow at ten call Bob, about his new book”
let me think that he use an old version of the app.
I didn’t ran Reminders with old systems but I faced a resembling change in Notes where old versions used two lines when current one use three ones (at least if my memory is right).

As the asker gave its mail address in his message I asked him for details but have no answer at this time.

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) dimanche 5 février 2017 18:13:33

hello

Sierra 10.2.4
reminders 4

in the end I wrote this…


-- Created based on code found in these sources:
-- https://discussions.apple.com/thread/3956557?start=0&tstart=0
-- https://discussions.apple.com/thread/3678943?start=0&tstart=0

-- ask the user for a file:
-- set theFile to (choose file)

-- read the file contents:
set theFileContents to (read file "Users:alessandromelchiorre:Dropbox:Reminders.txt")

--Change this to the path to your downloaded text file with your tasks in it! (Note the : instead of a / between folders) Or, just name them Reminders.txt and put them in your downloads folder

-- break out the lines/paragraphs of text:
set theLines to paragraphs of theFileContents

set AppleScript's text item delimiters to ": "

-- now iterate through those lines, one by one:
repeat with eachLine in theLines
	tell application "Fantastical 2"
		activate
		parse sentence (text item 1 of eachLine) notes (text item 2 of eachLine) with add immediately
		delay 2
	end tell
	--set AppleScript's text item delimiters to ""
end repeat

what do you think?

Are you really using the application Reminders.app ?

I found no file named Reminders.txt on my machine.

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) lundi 6 février 2017 10:32:32

dear Yvan,

in this case I use fantastical because of its parse capabilities of natural language…
the file “Reminders.txt” is to be created by you: it is a simple txt file with a reminder per line.
My goal is to have in one line not only a reminder but also its note as in the following example:

“tomorrow at ten call Bob, about his new book”

where the first part “tomorrow at ten call Bob” is the name of the reminder
where the second part “about his new book” is the body of the reminder

it seems simple but actually at least for me is not

salut à Vallauris, beautiful village!

amlechi

dear Yvan

another useful script is


set theFileContents to (read file "Users:alessandromelchiorreib:Dropbox:Reminders.txt")

--Change this to the path to your downloaded text file with your tasks in it! (Note the : instead of a / between folders) Or, just name them Reminders.txt and put them in your downloads folder

set theLines to paragraphs of theFileContents

repeat with eachLine in theLines
	tell application "Reminders"
		set mylist to list "Inbox" -- Change this to your Reminders list name
		tell mylist
			make new reminder at end with properties {name:eachLine, due date:current date}
		end tell
	end tell
end repeat

(*
-- Properties that can be set for each task
name (text) : the name of the reminder
id (text, r/o) : the unique identifier of the reminder
body (text) : the notes attached to the reminder
completed (boolean) : Is the reminder completed?
completion date (date) : the completion date of the reminder
container (list, r/o) : the container of the reminder
creation date (date, r/o) : the creation date of the reminder
due date (date) : the due date of the reminder
modification date (date, r/o) : the modification date of the reminder
remind me date (date) : the remind date of the reminder
priority (integer) : the priority of the reminder
*)


and actually it works very well… my problem (cause I am a newbie :slight_smile: ) is how to add properties in a proper way and how to declare the related variables (for instance note or completion date, etc.)
If you can please help,
Thanks

amelchi

I apologizes but as far as I know, there is no note property in a reminder.
Below are some instructions borrowed from my script which try to define some complementary properties.

if not (exists (first reminder whose name is "call Bob")) then
		tell me # Required because we can't work upon dates in the tell application "Reminders" block
			set dueDate to (date (get short date string of (current date))) + (1 * days) + (10 * hours)
			set remindMeDate to dueDate - (2 * hours)
			set creationDate to currentDate
			set modificationDate to creationDate + (1 * minutes)
			set completionDate to currentDate + (5 * minutes)
		end tell
		tell list "Test"
			set newReminder to make new reminder with properties {name:"call Bob", body:" about his new book", due date:dueDate, remind me date:remindMeDate, priority:2, creation date:creationDate, modification date:modificationDate, completion date:completionDate, completed:true}
		end tell
	else
		set newReminder to (first reminder whose name is "call Bob")
	end if
	tell newReminder
		name --> "call Bob"
		due date --> date "mercredi 8 février 2017 à 10:00:00"
		body --> " about his new book"	
		priority --> 2
		creation date --> date "mardi 7 février 2017 à 19:34:32"
		modification date --> date "mardi 7 février 2017 à 19:34:32"
		completion date --> missing value
		completed --> false
	end tell

As you may see, we can’t set modification date, completion date and completed.

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mardi 7 février 2017 20:26:00