Last active
August 9, 2023 16:38
-
-
Save Zyber17/b4ba273e61551a2faf22 to your computer and use it in GitHub Desktop.
Copies events from one calendar to another. Can be continually run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repeat | |
tell application "System Events" to set CalIsRunning to (name of processes) contains "Calendar" | |
tell application "Calendar" | |
if CalIsRunning is false then | |
activate | |
delay 10 # If Calendar isn't running and needs to be launched, the script will fail becuase Calendar isn't ready to accept commands as soon as it's launched. | |
end if | |
set workEvents to (get events of calendar "Calendar 1") | |
set testEvents to (get events of calendar "Calendar 2") | |
set testEventDates to {} | |
repeat with minorEve in testEvents | |
copy (start date of minorEve) to end of testEventDates | |
end repeat | |
repeat with eve in workEvents | |
if ((start date of eve) is not in testEventDates) then # Makes the assumption that events have unique start dates. If two or more events occur at the same start time, only one will be copied. | |
duplicate eve to the end of events of calendar "Calendar 2" | |
end if | |
end repeat | |
end tell | |
set CalIsRunning to false | |
delay (5 * 60) | |
end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment