If this has been covered elsewhere, please point me to it. I’ve seen the post on incrementing the anniversary event where the anniversary date was read from contacts. I’m looking for a script for my hockey league, where I can put in the first game of the season, e.g. GeriHatTricks game 1 of 15, set it up as a recurring event for 15 weeks but have each subsequent event name read “…game 2 of 15”, “…game 3 of 15” etc.
I am not a coder and haven’t written any programs since college using Fortran in the early 80’s, but I can usually read the code well enough to understand how it is working.
Any help with this would be appreciated.
This is pretty easy to do with a loop.
The thing to bear in mind is that Calendar.app events need 3 elements - a Summary (what you see on the Calendar itself), a start and an end time.
The following script should get you started:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- adjust these figures as needed
set SeasonStartDate to date "September 1 2024"
-- start time of the game (in 24 hour format)
set gameStartTime to 16 * hours
-- how long is each game (used to calculate event end time)
set gameDuration to 1 * hours
-- loop 15 times
repeat with gameNo from 1 to 15
-- calculate the start date of this game, based on the Season Start Date and week offset
set thisGameStartDate to SeasonStartDate + ((gameNo - 1) * 7 * days)
-- set the game start time
set time of thisGameStartDate to gameStartTime
-- and end time
set thisGameEndDate to thisGameStartDate + gameDuration
-- now go make an event on the calendar
-- need to edit the Calendar name as appropriate
tell application "Calendar"
make new event at end of events of calendar "Game Schedule" with properties {summary:"Game " & gameNo & " of 15", start date:thisGameStartDate, end date:thisGameEndDate}
end tell
end repeat
I’ll give this a shot. Thanks