I was unable to get all the way to my ultimate goal of creating repeating calendar events with open file alerts. But, i did at least solve this question of how to create a repeating calendar event in AppleScript, so here it is.
The main issue is that you can't actually create a repeating event. You have to create a static event, then modify that event to repeat. Here's the code that is working for me:
#Event name & description
set title to "event title"
set taskDescription to "The Description"
# which dates to use?
set startDate to date ("07/21/2020")
set endDate to date ("07/21/2020") -- last date to include
# which calendars contain the events?
set thisCalendar to "Automator"
# how many days in between repeats?
set interval to 2
tell application "Calendar"
tell calendar thisCalendar
make new event at end with properties {description:taskDescription, summary:title, start date:startDate + 540 * minutes, end date:startDate + 540 * minutes} # creates event at 9am, modify to suit.
set theEvents to (every event where its start date is equal to startDate + 540 * minutes)
set recurrence of item 1 of theEvents to "FREQ=DAILY;INTERVAL=" & interval
end tell
end tell
If you don't have a local calendar called "Automator", then this might give you problems, I'm not sure. Feel free to change the calendar name if needed.
launchd
. – CJK Jul 18 '20 at 4:57