I want to remove all alarms / notifications (there may be none, one or more than one) of all overdue reminders in the Reminders app of OS X.
I tried to use AppleScript for this, but having troubles understanding how to properly work with objects. I figured out how to get all those reminders, though:
tell application "Reminders"
activate
set myRemList to every reminder whose due date is less than (current date) as list
repeat with myitem in myRemList
log (get properties of myitem)
end repeat
end tell
Is this code usable (any fatal mistakes I'm not aware of)? How can I remove the alarms?
[Edit]
Here's an example of what I want to achieve:
Consider this one which reminds me to call Jon Doe:
The item is due today and a reminder is set to notify me at 14.00 (2 pm). When my planning has changed there are few of those items, popping up their reminders ("call jon doe" in this example). I want that "remind me" property to be unticked for all overdue items.
Best Answer
There was no fatal mistake in the code shown in the OP, however the proper way to use
current date
, in this case, is by letting the current application do it, not Reminders, as it actually errors out but does recover, hence not fatal. Nonetheless one should write code that's not going to needlessly error out. So, before thetell application "Reminders"
code block, setcurrent date
to a variable and use the variable within the Reminders code block, as shown in the code further below.Note that I personally do not use the Reminders app, however going by what's exposed in Reminders's AppleScript Dictionary, the following properties, not marked as
r/o
, are what can be programmatically changed for thereminder
class.As a test, I created a reminder named "Test" and set the remind me [√] check box to yesterdays date, so as to conform with the search parameter in the code further below.
Then, in Script Editor, I used the following line of code to get its properties.
It returned:
{due date:date "Saturday, September 10, 2016 2:00:00 PM", modification date:date "Sunday, September 11, 2016 1:49:35 PM", class:reminder, body:missing value, completed:false, completion date:missing value, id:"3F0EF538-5DF6-4F1C-8024-922B5D45EB9B", name:"Test", container:list id "9EB58C9B-EF63-4B72-88C3-A4FFA3C7272F" of application "Reminders", priority:0, creation date:date "Sunday, September 11, 2016 1:49:13 PM", remind me date:date "Saturday, September 10, 2016 2:00:00 PM"}
I then manually unchecked the remind me [] check box and ran the
... get properties ...
code again.It returned:
{due date:missing value, modification date:date "Sunday, September 11, 2016 1:49:35 PM", class:reminder, body:missing value, completed:false, completion date:missing value, id:"3F0EF538-5DF6-4F1C-8024-922B5D45EB9B", name:"Test", container:list id "9EB58C9B-EF63-4B72-88C3-A4FFA3C7272F" of application "Reminders", priority:0, creation date:date "Sunday, September 11, 2016 1:49:13 PM", remind me date:missing value}
The primary difference between the two was the first and last items in the list, i.e., the
due date
and theremind me date
, went fromdue date:date "Saturday, September 10, 2016 2:00:00 PM"
todue date:missing value
with the same forremind me date
, havingremind me date:missing value
too.So I tested the code below using both preferences,
due date
andremind me date
just to see if there was any difference and there wasn't, as removing one removed the other.The following code will remove both the
due date
andremind me date
from any Reminder that's older thencurrent date
and has not been markedcompleted
, at the time the code is run, as this is what occurs, at least to the properties of areminder
, in one has manually unchecked the remind me [] check box.The code above can also be written as shown below. This actually is a better way to write it, as it makes for a smaller list returned because it's then only creating a list of items (
reminders
) that have not yet been marked as completed. As after all, ones already marked as completed are not going to trigger an "alarm".Based upon your edited OP, if this does not do what is needed, then I do not know what else I can offer, as I can only work within what properties are exposed and editable.
Note: I was not able to reproduce the reminder as shown in your edit, i.e. the line starting with "due" directly under the [] At a Location check box and above "repeat None". However, what is now offered as the answer to "remove all alarms of all overdue reminders with AppleScript on OS X" does mimic the manual action of unchecking the remind me [] check box, which is what you've now asked for through the edit made to the OP. I hope this resolves your issue.