Code Comments
Programming Forum and web based access to our favorite programming groups.For people suffering from duplicate entries in their ICal database,
here's a script that identifies and then removes them. This used to be
available on Apple's discussion boards, but then it disappeared. It's
a very helpful script for anyone who's suffered the consequences of a
poorly executed synchronization from one calendar application to
another.
-- Delete duplicates from iCal v2 --
-- Applescript -- John Maisey 27/5/5 --
-- Modified 2/6/5 --
-- Duplicates being events with same title and start time in one
calendar--
tell application "iCal"
set sourceCal to first calendar whose title is (item 1 of (choose from
list =AC
(title of (every calendar) as list) with prompt "Choose calendar to
delete duplicates"))
set testThen to (current date) -- time tester
set mySumms to summary of events of sourceCal
set myStarts to start date of events of sourceCal
set myUIDs to uid of events of sourceCal
end tell
script myStuff
property aSumms : {}
property aStarts : {}
property aUIDs : {}
property aDeletes : {}
end script
set myStuff's aSumms to mySumms
set myStuff's aStarts to myStarts
set myStuff's aUIDs to myUIDs
set myLength to length of myStuff's aStarts
repeat with aNum from 1 to (myLength - 1)
set thisSumm to (item aNum of myStuff's aSumms)
set thisStart to (item aNum of myStuff's aStarts)
repeat with bNum from (aNum + 1) to myLength
set thatSumm to (item bNum of myStuff's aSumms)
set thatStart to (item bNum of myStuff's aStarts)
if thisSumm is equal to thatSumm and thisStart is equal to thatStart
then
set the end of myStuff's aDeletes to (item bNum of myStuff's aUIDs)
exit repeat
end if
end repeat
end repeat
set n to count of myStuff's aDeletes
tell application "iCal"
repeat with myDel in myStuff's aDeletes
delete (every event of sourceCal whose uid is myDel)
end repeat
display dialog (n & " duplicates deleted in " & ((current date) -
testThen) & " seconds") as text -- time tester=20
end tell
--
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.