After a bit of messing around...
The UI doesn't do what you think it does. It doesn't delete one event in a recurring series, it sets it as "excluded" by adding the start date and time of that occurrence to the event's excluded dates
property (which is a list
).
So after setting up a 3-day recurring event, selecting the middle day, and getting the events properties
Code used to do that
tell application "Calendar"
set defaultsReply to (do shell script "defaults read com.apple.ical SelectedEvents")
set localUIDs to {}
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, quote}
set resultItems to text items of defaultsReply
set AppleScript's text item delimiters to TID
repeat with i from 1 to (count resultItems)
if i mod 2 = 0 then set end of localUIDs to resultItems's item i
end repeat
return properties of event id (item 1 of localUIDs) of calendar "Work"
end tell
...the result is (with added line breaks to make the relevant piece obvious:
{id:"0D3D0DDB-1503-4028-BA7A-38FB5A235ED4", recurrence:"FREQ=DAILY;INTERVAL=1;UNTIL=20230406T225959Z", stamp date:date "Monday, 3 April 2023 at 19:27:30", class:event, url:missing value, end date:date "Tuesday, 4 April 2023 at 14:15:00",
excluded dates:{},
description:missing value, summary:"New Event", location:missing value, allday event:false, start date:date "Tuesday, 4 April 2023 at 13:15:00", sequence:2, status:none}
After deleting the middle event through the UI then selecting the first:
{id:"0D3D0DDB-1503-4028-BA7A-38FB5A235ED4", recurrence:"FREQ=DAILY;INTERVAL=1;UNTIL=20230406T225959Z", stamp date:date "Monday, 3 April 2023 at 19:27:30", class:event, url:missing value, end date:date "Tuesday, 4 April 2023 at 14:15:00",
excluded dates:{date "Wednesday, 5 April 2023 at 13:15:00"},
description:missing value, summary:"New Event", location:missing value, allday event:false, start date:date "Tuesday, 4 April 2023 at 13:15:00", sequence:2, status:none}
So what you need to do is get the date and start time of the occurrence you want to "delete" and add it to the event's excluded dates
list. This would remove the Tuesday occurrence, now leaving only the Thursday one on the calendar:
tell application "Calendar"
set excluded dates of event id "0D3D0DDB-1503-4028-BA7A-38FB5A235ED4" of calendar "Work" to (excluded dates of event id "0D3D0DDB-1503-4028-BA7A-38FB5A235ED4" of calendar "Work" & {date "Tuesday, 4 April 2023 at 13:15:00"})
end tell
That might be enough to get you started.