I’m making an attempt to make a mirror of 1 calendar into one other for the a set time frame (say 1 week). Nonetheless once I run the script beneath it solely copies non-recurring occasions. Any tips on easy methods to repair that is a lot appreciated
use AppleScript model "2.4" -- Yosemite (10.10) or later
use scripting additions
set SourceCalendarName to "VV Important"
set DestinationCalendarName to "VV Mirror"
set meetingProxy to "VV Assembly"
set at this time to present date
set numberofdays to 7
set startDay to ((present date) - (1 * days))
set time of startDay to 0
set endDay to ((startDay) + (numberofdays * days))
--set time of endDay to
set numberOfEventsAdded to 0
inform software "Calendar"
set sourceCalendar to calendar SourceCalendarName
set destinationCalendar to calendar DestinationCalendarName
(*
inform destinationCalendar
delete (occasions)
finish inform
*)
set sourceEventList to (occasions of sourceCalendar the place (its begin date > startDay) and (its begin date < endDay))
repeat with eventIdx from 1 to size of sourceEventList
set newEvent to merchandise eventIdx of sourceEventList
--repeat with newEvent in (get occasions of sourceCalendar whose (begin date is larger than startDay) and (begin date is lower than endDay))
set existingEventList to (occasions of destinationCalendar)
set eventExists to false
if size of existingEventList just isn't 0 then
repeat with checkEvent in existingEventList
if ((begin date of checkEvent = begin date of newEvent) and (finish date of checkEvent = finish date of newEvent)) then
set eventExists to true
exit repeat
finish if
finish repeat
finish if
if eventExists is fake then
inform destinationCalendar
set destEvent to (make new occasion at finish of occasions with properties {begin date:begin date of newEvent, finish date:finish date of newEvent, abstract:meetingProxy, allday occasion:allday occasion of newEvent, description:(uid of newEvent as textual content)})
if recurrence of destEvent just isn't lacking worth then
set recurrence of destEvent to recurrence of newEvent
finish if
finish inform
finish if
--set numberOfEventsAdded to (numberOfEventsAdded + 1)
finish repeat
finish inform