Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to iterate through iCal events in Applescript

42 views
Skip to first unread message

mcnesium

unread,
Mar 26, 2015, 5:21:55 AM3/26/15
to
Lets challenge stackexchange[1] by crossposting my question here:

I am trying to iterate through the events in a calendar to copy them to
another:

tell application "iCal"
set localEvents to events of calendar "localCalendar"
set remoteEvents to events of calendar "remoteCalendar"
repeat with theLocalEvent in localEvents
if theLocalEvent is not in remoteEvents
copy theLocalEvent to end of events of calendar
"remoteCalendar"
end if
end repeat
end tell

This throws the following error:

error "«class wrev» id \"137CC1CB-43A8-445D-AD15-4ED6DFBCFA64\" of
«class wres» id \"08F222B5-C63B-4631-BE34-43D878F184D1\" of application
\"iCal\" kann nicht in Typ vector umgewandelt werden." number -1700
from «class wrev» id "137CC1CB-43A8-445D-AD15-4ED6DFBCFA64" of «class
wres» id "08F222B5-C63B-4631-BE34-43D878F184D1" to vector

So for now I first create a list of UIDs of the events to check before
I copy them if they are not in the list:

tell application "iCal"
set localEvents to events of calendar "localCalendar"
set remoteEvents to events of calendar "remoteCalendar"
set listOfRemoteEvents to {}
repeat with theRemoteEvent in remoteEvents
copy (uid of theRemoteEvent) to end of listOfRemoteEvents
end repeat
repeat with theLocalEvent in localEvents
if (uid of theLocalEvent) is not in listOfRemoteEvents then
copy theLocalEvent to end of events of calendar
"remoteCalendar"
end if
end repeat
end tell

This works, but I am sure that it's the worst algorithm in the world.
So I am wondering how I can iterate through the calendar more
gracefully.





[1]:
http://apple.stackexchange.com/questions/178222/how-to-iterate-through-ical-events-in-applescript


Patrick Stadelmann

unread,
Mar 28, 2015, 1:14:36 PM3/28/15
to
In article <cni1dh...@mid.dfncis.de>,
mcnesium <mcne...@versteht.es> wrote:

Try changing :

if theLocalEvent is not in remoteEvents

to

if {theLocalEvent} is not in remoteEvents

Patrick
--
Patrick Stadelmann <Patrick.S...@unine.ch>
0 new messages