He estado creando un script de Apple que duplica los elementos del calendario de nuestro calendario de iCloud de familia compartida a un calendario de Outlook relacionado con el trabajo con el mismo nombre (dirección de correo electrónico diferente).
El siguiente script se ha generado iterativamente con ChatGPT, pero tiene al menos 1 error de sintaxis que no puedo solucionar, relacionado con el aparentemente inexistente prevalence
Propiedad de un evento calendario.App en la siguiente línea:
-- NOTE: the next line yields a syntax error "Anticipated class identify however discovered identifier."
set occurrencesList to each prevalence of thisEvent
¿Alguien puede ayudarme con este guión?
-- Path to a file the place we retailer the occasion UIDs
set uidFilePath to "~/Paperwork/icloud_event_uids.txt"
-- Create or learn the checklist of already processed occasion UIDs
set uidFile to open for entry (POSIX path of uidFilePath) with write permission
attempt
set processedUIDs to learn uidFile as textual content
on error
-- If file doesn't exist, create an empty checklist
set processedUIDs to ""
finish attempt
inform software "Calendar"
-- Choose the iCloud calendar
set sourceCalendar to calendar "Household" -- Substitute "iCloud" with the precise calendar identify if wanted
set eventList to each occasion of sourceCalendar
-- Entry Outlook software
inform software "Microsoft Outlook"
-- Choose the Outlook calendar (change with the identify of your required calendar)
set targetCalendar to calendar "Calendar" -- Substitute "Calendar" with the identify of your Outlook calendar
-- Get the present date for comparability
set currentDate to present date
set thirtyDaysAgo to currentDate - (30 * days)
-- Normalize currentDate and thirtyDaysAgo to UTC
set currentDateUTC to convertToUTC(currentDate)
set thirtyDaysAgoUTC to convertToUTC(thirtyDaysAgo)
-- Verify for occasions older than 30 days in Outlook and take away them
set outlookEventList to each calendar occasion of targetCalendar
repeat with outlookEvent in outlookEventList
set eventEnd to finish time of outlookEvent
set eventEndUTC to convertToUTC(eventEnd)
if eventEndUTC < thirtyDaysAgoUTC then
-- Take away occasion if its finish time is older than 30 days
delete outlookEvent
-- Take away the UID of the deleted occasion from the processed checklist
set eventUID to topic of outlookEvent -- Use the topic or one other distinctive property to trace this
set processedUIDs to removeUID(eventUID, processedUIDs)
finish if
finish repeat
repeat with thisEvent in eventList
-- Get the beginning time, finish time, abstract, and UID of the iCloud occasion
set eventStart to begin date of thisEvent
set eventEnd to finish date of thisEvent
set eventSummary to abstract of thisEvent
set eventLocation to location of thisEvent
set eventDescription to description of thisEvent
set eventUID to id of thisEvent -- iCloud distinctive identifier (UID)
-- Normalize occasion begin and finish instances to UTC
set eventStartUTC to convertToUTC(eventStart)
set eventEndUTC to convertToUTC(eventEnd)
-- Verify if the occasion UID has already been processed
if eventUID just isn't in processedUIDs then
-- Course of this occasion (e.g., duplicate it into Outlook)
-- Verify if it is a recurring occasion
if recurrence of thisEvent just isn't lacking worth then
-- Deal with recurring occasion by extracting all occurrences
set recurrenceRule to recurrence of thisEvent
-- NOTE: the next line yields a syntax error "Anticipated class identify however discovered identifier."
set occurrencesList to each prevalence of thisEvent
repeat with prevalence in occurrencesList
-- Get begin and finish time for every prevalence
set occurrenceStart to begin date of prevalence
set occurrenceEnd to finish date of prevalence
-- Normalize prevalence begin and finish instances to UTC
set occurrenceStartUTC to convertToUTC(occurrenceStart)
set occurrenceEndUTC to convertToUTC(occurrenceEnd)
-- Verify if the prevalence already exists in Outlook
set eventExists to false
set outlookEventList to each calendar occasion of targetCalendar
repeat with outlookEvent in outlookEventList
set outlookEventStart to begin time of outlookEvent
set outlookEventStartUTC to convertToUTC(outlookEventStart)
if (outlookEventStartUTC is occurrenceStartUTC) and (topic of outlookEvent is eventSummary) then
set eventExists to true
exit repeat
finish if
finish repeat
-- If the prevalence doesn't exist, create it
if eventExists is fake then
make new calendar occasion at targetCalendar with properties {topic:eventSummary, begin time:occurrenceStart, finish time:occurrenceEnd, location:eventLocation, content material:eventDescription}
finish if
finish repeat
else
-- If it is a single (non-recurring) occasion, course of as common
set eventExists to false
set outlookEventList to each calendar occasion of targetCalendar
repeat with outlookEvent in outlookEventList
set outlookEventStart to begin time of outlookEvent
set outlookEventStartUTC to convertToUTC(outlookEventStart)
if (outlookEventStartUTC is eventStartUTC) and (topic of outlookEvent is eventSummary) then
set eventExists to true
exit repeat
finish if
finish repeat
-- If the occasion doesn't exist, create it
if eventExists is fake then
make new calendar occasion at targetCalendar with properties {topic:eventSummary, begin time:eventStart, finish time:eventEnd, location:eventLocation, content material:eventDescription}
finish if
finish if
-- Append this occasion UID to the checklist of processed UIDs
set processedUIDs to processedUIDs & eventUID & linefeed
write processedUIDs to uidFile
finish if
finish repeat
finish inform
finish inform
-- Shut the file after processing
shut entry uidFile
-- Operate to take away UID from the processed checklist
on removeUID(thisUID, uidList)
set textItemDelimiters to linefeed
set uidListItems to each textual content merchandise of uidList
set newUIDList to {}
repeat with currentUID in uidListItems
if currentUID just isn't thisUID then
set finish of newUIDList to currentUID
finish if
finish repeat
return (newUIDList as textual content)
finish removeUID
-- Operate to transform date to UTC
on convertToUTC(inputDate)
set timeZoneOffset to (time zone of (present date)) -- Get the present time zone offset
set utcDate to inputDate - timeZoneOffset -- Convert to UTC by subtracting the offset
return utcDate
finish convertToUTC