Help with iCal - newbie

I am new to both applescript and automator but not new to programming. My problem is this:
I am trying to work with iCal and Google calendar. I can subscribe to my google calendar via the private URL all my Google calendar appointments/events will be populated in iCal. This allows me to enter things while away from home. My problem is that the google events come in ‘read only’ and with no alert. I would prefer to have these events moved to say my ‘Home’ calendar and add an alert. Do this need to be scripted or can automator handle this?

Model: iMac
AppleScript: ?
Browser: FireFox2.0/Safari
Operating System: Mac OS X (10.4)

I’m not a newbie, and I’d be very interested to know the answer.


My take on it would be something like this:

-- John Maisey -- [url=][/url] -- 14 Sept 2007
set mySource to "source calendar name" -- Change this
set myDestination to "destination calendar name" -- Change this
tell application "iCal"
	-- Get a list of the events.
	set myEvents to events of calendar mySource
	-- Loop through them.
	repeat with myEvent in myEvents
		-- Check for similar event in destination calendar.
		if (events of calendar myDestination whose summary contains (summary of myEvent) and start date is equal to (start date of myEvent)) is equal to {} then
			-- Get all properties of the event and make a copy of the relevant ones.
			set evtProp to properties of myEvent
			set myEventProperties to {location:location of evtProp, url:url of evtProp, end date:end date of evtProp, recurrence:recurrence of evtProp, summary:summary of evtProp, start date:start date of evtProp, excluded dates:excluded dates of evtProp, allday event:allday event of evtProp, description:description of evtProp, status:status of evtProp}
			-- To fix all day event bug.
			if allday event of myEventProperties is true then set end date of myEventProperties to ((end date of myEventProperties) + 1 * days)
			-- Make new event in destination calendar.
			set myNewEvent to make new event at the end of events of calendar myDestination with properties myEventProperties
			-- This example alarm is a display alarm one hour before.
			make new display alarm at the end of display alarms of myNewEvent with properties {trigger interval:-60}
		end if
	end repeat
end tell

You need to change the ‘set mySource’ and ‘set myDestination’ lines to the right calendars. You will probably want to extend the alarm section.

While you are testing it, I suggest you might want to set up a test calendar to receive the events.

I did play around with using ‘copy’ and ‘duplicate’ on the events. I was surprised it worked at all. It certainly produced unexpected results which were due to the two events having the same UID. I wouldn’t suggest you try it.

Best wishes

John M

(Edit: spelling)

Thanks so much. I’ll try it this weekend.