ICal and subscribed calendars with MobileMe using AppleScript

I am having the same problem as many of you; I have a MobileMe account which does not sync the calendars I have in iCal that are subscriptions. I found this great script online which I'll post below. I don't know anything about AppleScript so I'm just copy-pasting. I want it to work, but I'm getting the error "The variable theOldEvent is not defined." right around the line "if similar_found is true then set theOldSummary to the summary of theOldEvent" kinda near the middle. Like I said, I don't know anything about AppleScript. So my question is; how can I fix this error and/or is there some better way of using AppleScript/Automator to do this same thing? Thanks!
Script to duplicate Calendar orgCalendar into target dupCalendar
E.H. 12.9.2008
property myCopies : 0
property myUpdates : 0
property myObsoletes : 0
property orgCalendar : "Sekretariat"
property dupCalendar : "Sekretariat copy"
property dupEvents : {}
property myDeletes : {}
set myCopies to 0
set myUpdates to 0
set myObsoletes to 0
set dupEvents to {}
tell application "iCal"
-- set theCalendars to every calendar
set theCalendarNames to title of every calendar
set theOrgCalendar to a reference to calendar orgCalendar
if theCalendarNames contains dupCalendar then
set theCalendar to a reference to calendar dupCalendar
else
set theCalendar to make new calendar with properties {title:dupCalendar}
--set theCalendar to make new calendar with properties {title:dupCalendar, color:"{65535, 0, 0}"}
end if
set the eventList to uid of every event of theOrgCalendar as list
set the eventCount to the count of the eventList
repeat with theUId in eventList
tell theOrgCalendar
set theEvent to (the first event whose uid is theUId)
-- set theProperties to the properties of theEvent as record
set theDate to the start date of theEvent
set theSummary to the summary of theEvent
set theStampDate to the stamp date of theEvent
end tell
tell theCalendar
try
set theOldEvent to (the first event of theCalendar whose (start date) is theDate as date)
set similar_found to true
on error
set similar_found to false
set theEndDate to the end date of theEvent
set theAllDay to the allday event of theEvent
set theLocation to the location of theEvent
-- Funny construction to work araund the fact that location may be missing a value
try
if theLocation is equal to "" then
end if
on error
set theLocation to ""
end try
set theDescription to the description of theEvent
try
if theDescription is equal to "" then
end if
on error
set theDescription to ""
end try
if theAllDay is true then -- work around a funny bug with all day events
set theDate to (theDate as date) + 2 * hours
set theEndDate to (theEndDate as date) + 2 * hours
end if
set newEvent to make new event at end with properties {summary:theSummary, location:theLocation, start date:theDate, end date:theEndDate, allday event:theAllDay, description:theDescription}
-- make new event at end with properties theProperties
set the end of dupEvents to (the uid of newEvent)
set myCopies to (myCopies + 1)
end try
end tell
set second_necessary to false
if similar_found is true then
set theOldSummary to the summary of theOldEvent
if theSummary is not equal to theOldSummary then
--is there a different one?
try
set theOldEvent1 to (the second event of theCalendar whose (start date) is theDate as date)
set theOldSummary to the summary of theOldEvent1
if theSummary is equal to theOldSummary then
set theOldEvent to theOldEvent1
set the end of dupEvents to (the uid of theOldEvent)
else
-- cycle repeat ?
end if
on error
-- beep
try
set theEvent1 to (the second event of theOrgCalendar whose (start date) is theDate as date)
set second_necessary to true
on error
set the end of dupEvents to (the uid of theOldEvent)
end try
end try
else
set the end of dupEvents to (the uid of theOldEvent)
end if
if second_necessary is true then
set theEndDate to the end date of theEvent
tell theCalendar
set theOldEvent to make new event at end with properties {summary:theSummary, start date:theDate, end date:theEndDate}
end tell
set the end of dupEvents to (the uid of theOldEvent)
end if
set theOldStampDate to the stamp date of theOldEvent
if theStampDate is greater than theOldStampDate then
-- update the event
set summary of theOldEvent to theSummary -- capitalization may have changed
set theAllDay to the allday event of theEvent
set allday event of theOldEvent to theAllDay
set theEndDate to the end date of theEvent
if theAllDay is true then -- work around a funny bug with all day events
set theEndDate to (theEndDate as date) + 2 * hours
end if
set end date of theOldEvent to theEndDate
set theDescription to the description of theEvent
try
if theDescription is equal to "" then
end if
on error
set theDescription to ""
end try
set description of theOldEvent to theDescription
set myUpdates to myUpdates + 1
end if
end if
end repeat
end tell
-- Delete obsolete events
set myObsoletes to 0
set myDeletes to {}
tell application "iCal"
set myUIDs to uid of events of theCalendar
end tell
repeat with myUID in myUIDs
if dupEvents does not contain myUID then
set the end of myDeletes to myUID
set myObsoletes to (myObsoletes + 1)
end if
end repeat
tell application "iCal"
repeat with myDel in myDeletes
delete (every event of theCalendar whose uid is myDel)
end repeat
end tell
-- delete duplicates
set myDeletes to {}
tell application "iCal"
set myStarts to start date of events of theCalendar
set mySummaries to summary of events of theCalendar
set myUIDs to uid of events of theCalendar
set myLength to length of myUIDs
end tell
repeat with i from 1 to (myLength - 1)
set thisStart to (item i of myStarts)
set thisSumm to (item i of mySummaries)
repeat with j from (i + 1) to myLength
set thatStart to (item j of myStarts)
set thatSumm to (item j of mySummaries)
if thisSumm is equal to thatSumm and thisStart is equal to thatStart then
set the end of myDeletes to (item j of myUIDs)
exit repeat
end if
end repeat
end repeat
set n to count of myDeletes
tell application "iCal"
repeat with myDel in myDeletes
delete (every event of theCalendar whose uid is myDel)
end repeat
-- set the visible of calendar theCalendar to false
end tell
display dialog (myCopies & " records duplicated, " & myUpdates & " records updated and " & myObsoletes & " obsolete ones deleted") as text

No longer an issue.

Similar Messages

  • ICal don't sincronize with MobileMe? somebody knows?

    iCal don't sincronize with MobileMe? somebody knows?

    Please post your system details when you have a question - and more detail would help: it's difficult to give a cogent answer when the question is as vague as this.
    If you haven't upgraded to the new MobileMe calendar then you should: it's no longer optional: please see
    http://homepage.mac.com/rfwilmut/notes/calendarsync.html
    If you are using Leopard or Tiger please particularly note the comments regarding those systems.

  • Upon syncing my iPhone and mac all of my ical and iPhone calendar events have duplicated. how can i fix this and avoid it in the future?

    upon syncing my iPhone and mac all of my ical and iPhone calendar events have duplicated. how can i fix this and avoid it in the future?

    Greetings,
    Questions:
    1. What version of the Mac OS are you running (Apple > About this Mac)?
    2. What version of the iOS are you running (Settings > About)?
    3. Do you backup your computer (http://support.apple.com/kb/HT1427)? 
    --- If you don't regularly backup your computer, now is the time to start.
    4. Do you backup your iPhone (http://support.apple.com/kb/ht1766)?
    Check the calendar list on the left hand side of iCal.  Is it that the individual events are duplicated or is it just that you have the same calendar listed more than once?  If its that you have more than 1 copy of each calendar, you can delete one of the duplicate calendars to eliminate the duplicates.
    If you find that it is the individual events that are duplicated then there are 2 options:
    1. Restore your computer iCal database or iPhone from a backup made before the duplication occurred.
    2. Use a duplication removal program (or do it by hand) to remove the duplicates: http://www.nhoj.co.uk/icaldupedeleter/
    If you have a backup made before the duplication occurred, reply back with what kind of backup you have and I'll suggest how to recover the calendars.
    To avoid this issue in the future:
    Keep regular backups.  They are your best defense against data anomalies which are a fact of life in computers (although hopefully rare).
    Keep your computer and iPhone software fully up to date (Apple > Software Update / Settings > General > Software Update).
    Make sure the date and time on your computer and iPhone are correct before you sync the two devices.
    Make sure the cable connections between the two is solid and that the cable shows no signs of physical damage.
    Hope that information helps.

  • Help needed to sync ical and google calendar

    Hello, I am hoping someone can help me set up my ical and google calendar so they can sync from one to the other. I originally have ical with everything on it and I need to get it to sync with google. I have no problem exporting from ical and importing in google but I do have a problem setting it up to sync back and forth. Any help would be greatly appreciated.
    Thanks

    You may want to look at Spanning Sync.
    http://spanningsync.com/

  • Ical subscribed calendar with Iphone?

    I have a client that uses Ical for multiple calendars. All are his, except for one, which he subscribes to.
    That one calendar is not listed on his Iphone. It is the only one missing.
    Is this normal or is there a way to turn on this functionality?

    This is how I managed to get a workround.
    Note my wife does not have a Mac, she only has a PC and uses her Iphone Calendar to share her appointments with me:
    Firstly I Set up a new user on my Mac for my wife, I then created her ICal account and set it to publish to the net and for it to sync with MobileMe. You can email to subscribed Calendar link to your own account and subscribe from the message
    Then go to this link and follow what they tell you to.
    http://www.jacksmac.com/JacksMac/Jacks_Mac_Blog/Entries/2008/8/21_iPhones_Calendar_Can_Show_iCalSubscriptions.html
    Once completed ICal checks the published Calendar and copies it to a local folder. You need to leave your Mac on for this to work.
    In addition to this I set up fast user switching which really helps this process. I did this by:
    System Preferences > Accounts > Login option (Bottom LHS of the screen) > Check the box saying Enable Fast user Switching.
    You will then see your login name appear on the top RHS of your screen next to spotlight, switch your user to the second profile, Launch ICal and set Mobile Me to sync and leave Ical open.
    Once you have done this switch back to your main profile and open ICal in the background, all Calendars should then sync through to your iphone and be updated every 15 minutes.
    NOTE IN ORDER FOR THIS TO WORK PROPERLY, YOU NEED TO LEAVE YOUR MAC SWITCHED ON AND LEAVE ICAL RUNNING IN BOTH PROFILES.

  • Is Publish and Subscribe part of MobileMe?

    I know I will be able to sync to other devices with my iPhone, iCal and MobileMe but I want other PEOPLE to see my calendars like I do right now with iCal using Publish and Subscribe.
    So my questions is; will I be still able to Publish and Subscribe with MobileMe?
    Oh, the calendars must be password protected as the notes will contain confidential company information.

    Publish-Subscribe Model
    Purpose
    This model defines how you publish messages to and receive messages from a well-known node. Such nodes are referred to as topics. You can use the model for:
    ·        Creating Message Producer to a Topic
    ·        Creating Message Consumer to a Topic
    ·        Managing Durable Subscriptions
    Chk this for more.
    http://help.sap.com/saphelp_nw04/helpdata/en/aa/34518672fa44c79340c1f61556443e/frameset.htm

  • Can you share an icloud calendar with someone using gmail?

    I manage all my calendars on icloud and want to share one of them with my partner, who uses gmail and android phone. The events do not show up on his phone. This is because its not possible to do this or because we are doing something wrong?

    You can only share a read/write calendar with another iCloud member. You can share a read-only calendar with a non-member: the recipient can subscribe to it in iCal. Just get them to open an iCloud account if they have Lion on their Mac.
    http://help.apple.com/icloud/#mm6b1a9479
    You forgot Windows.   Windows users get preferred privileges over Snow Leopard. 

  • How do I share iCal 5.0 calendars with PC's...

    Prior to Lion, PC XP users in my office could subscribe to my iCal calendars. As I understand it, in Lion, I can Share calendars, but do my PC users need to have an iCloud account? And if so, is XP even compatible with iCloud? And if not, what do I do?

    I'm afraid you can't do this in Leopard. I quote:
    'Features of the MobileMe Calendar that are not available with Mac OS X Leopard:
    Push updates. See this article for more information.
    The ability to share and accept shared calendars with others from within iCal. These changes can still be made at me.com/calendar.
    Subscribed calendar syncing.'
    (my italics)

  • Syncing selected calendars with MobileMe

    I use several calendars in iCal on my MacBook to schedule different events and locations at work. I want to sync only a few of these calendars to my iPhone. I can do this when sycning with iTunes, but with MobileMe it seems that I must sync all or none. Is there a way to sync selected calendars using MobileMe?

    Hello;
    I sync a Macbook and 2 iPhones via MobileMe. However the 2 iPhones receive the same alerts (reminders) for the events or appointments.
    Is it possible to sync only certain appointments to one iPhone and others to the second iPhone? It just doesnt make sense to receive the same alerts in the two iPhones since they are in different Calendars in the iCal?
    Thanks!

  • Sync my iphone calendar with MobileMe for the first time without deleting?

    I never used iCal, I only us the calendar on my iphone to remember appointments. Now I just got MobileMe and I want my iphone calendar to sync with mobileme (obviously for the first time). But when I turn on MobileMe calendar sync on my iPhone, I get the message that if I save that setting, all my events will be deleted from my phone!
    How can I start using MobileMe on my phone without losing all my events/appointments??
    And what's the logic behind this behavior? I don't get it.

    childlost,
    This is the expected behavior. When MobileMe Push is enabled on the iPhone, it replaces the existing information with what it finds on me.com.
    I'd recommend following this guide for the initial setup: http://www.apple.com/mobileme/setup/iphone/mac.html
    Hope this helps,
    Raleigh

  • ICal no longer synchronising with MobileMe

    My wife has an iMac and a MacBook both synchronising with (and via) MobileMe. Both Intel machines are running Snow Leopard.
    All were synchronising perfectly, including iCal, until as requested by MobileMe, I upgraded to the New Calendar.
    Now only the Imac synchronises correctly. TheMacBook returns a pop-up stating that the iCal has "either wrong ID login OR wrong Password" !
    (Le serveur n’a pas reconnu votre nom d’utilisateur ou votre mot de passe pour le compte « [email protected] ». Assurez-vous de les avoir correctement saisis.)
    I have stopped the synchronisation and cancelled the iDisk synchronising.
    Then connected again at the level of MacBook and logged again to the account. And synchronised again. It states first login for the calander.
    The MacBook synchronises but the calendar returns the error.
    My wife's account is sub (family) account of my main MobileMe account.
    Help me please as I really don't understand nor do I know what to do !
    Regards,
    Kevin in France

    Thanks for the effort and response. I was able to contact Apple Help and I downgraded back to the old mobileme iCal. The new mobileme iCal is very inflexible. The Month header takes a huge font. Fonts on appointments can't be changed and, as a result, appointments can be seen in their entirety. There are other very irritating things about the new iCal and my conclusion is that it's just a very weak attempt at Outlook and has a long way to go before it's usable. I just hope Apple doesn't cut us off the "old" calendar which works very well (and has for some time now)

  • ICal not syncing correctly with MobileMe

    For the last week or so, ever since MobileMe was being updated, my iCal synching with MobileMe and iPhone has stopped working correctly. When I enter a meeting into iCal, it syncs to MobileMe and therefore my iPhone.
    HOWEVER, any new calendar entries from the iPhone (or MobileMe's website directly), do not show up on iCal even after i try to manually Sync them. Furthermore, if I change the time of a meeting or call on iCal, a DUPLICATE meeting is created in MobileMe, thus polluting my calendar on the iPhone and MobileMe with multiple entries. When I am on the road, I can't figure out which is the correct meeting anymore.
    Not sure if this is due to new iTunes or the update with MobileMe servers last week.
    Here is what I have done to troubleshoot this to date:
    - In MobileMe preferences, I stopped synching my MacBook with MobileMe and wiped out all of the data on MobileMe. I rebooted my MacBook, then, I Reset Sync Data from iCal to MobileMe. It seeded fine, but still doesn't show any appointments created from the iPhone or within MobileMe on my iCal after re-syncing.
    - I deleted my MobileMe account on my iPhone. Rebooted iPhone. Re-added my MobileMe account to the iphone and synched the calendar. The calendar syncs and shows up, but still no appointments created on my iPhone or within MobileMe show on my iCal.
    - I have also tried to NARROW the variables of my issue by not synching ANYTHING ELSE other than iCal (no contacts, mail settings etc.). To No avail, still doesn't work.
    Any suggestions?? I sense there is something cached in the bowels of my iCal settings, but have no idea to re-set them to re-enable synching.

    I solved the issue. I took a risk and wiped my MobileMe account clean one last time, then RESET SYNCH Data from my MacBook to MobileMe.
    Then, I crossed my fingers and deleted my calendars on my iCal desktop.
    I then, chose RESET SYNCH Data FROM MobileMe TO MacBook pro - effectively overwriting my iCal with the same data I just uploaded into MobileMe.
    The result? Everything started working again. I added meetings to my calendar with my iPhone and they showed up on my iCal Desktop (MacBook). Yeah!

  • TS4006 my iCal in my new MacBook Air doesn't sync with the iCal data in my iPad despite having it "checked" (ON) in the system preferences iCloud. what else do i have to do to activate the iCal and have sync with my iPad?

    Issue: iCal
    I can't sync the iCal in my new MacBook Air with the existing iCal in my iPad. I went to system preferences (settings) to iCloud and checked the iCal to enable it to sync to my existing iPad iCal. Still nothing happened. It's strange because i successfully synced my contacts doing the same thing. Is there anything I have to have my iCal activated in my new MacBook Air?

    Welcome to the Apple Community.
    First check that all your settings are correct, that calendar syncing is checked on all devices (system preferences > iCloud on a mac and settings > iCloud on a iPhone, iPad or iPod).
    Make sure the calendars you are using are in your 'iCloud' account and not an 'On My Mac', 'On My Phone' or other non iCloud account (you can do this by clicking/tapping the calendar button in the top left corner of the application ), non iCloud calendars will not sync.
    If you are sure that everything is set up correctly and your calendars are in the iCloud account, you might try unchecking calendar syncing in the iCloud settings, restarting your device and then re-enabling calendar syncing settings.

  • After upgrading to Lion, iCal doesn't sync with MobileMe

    After my upgrade to the new Lion OS X, the iCal doesn't sync properly with MobileMe; events from MobileMe will go to iCal but they will not go from iCal to MobileMe.
    In System Preferences/Internet & Wireless/Mail, Contacts & Calendars: I've tried reinstalling MobileMe  and checking the Calendar & Reminders box, but that didn't work.
    In System Preferences/Internet & Wireless/MobileMe:  It doesn't show a calendar.  Clicked sync now, but that didn't work.
    Any suggestions?

    Tanner,
    In System Preferences/Internet & Wireless/MobileMe:  It doesn't show a calendar.  Clicked sync now, but that didn't work.
    I have not seen, nor am I aware of that setting in System Preferences.
    (Option + Click) on the Sync Icon in the Menu bar. If you do not see Sync status in the Menu bar, go to System Preferences...>MobileMe>Sync>...and check the "Show Sync status in menu bar.
    You will see these selections:
    Try the "Open Sync Diagnostics..." selection and you may get some clues.
    If that is unsuccessful, backup your calendars and choose Reset Sync Services...

  • ICal and Google Calendar: Why can't we all just get along

    OK. To start, I'll just lay out what I'd like from these two apps:
    I primarily use Google Calendar because I'm on different computers frequently and it's nice to have my calendar anywhere. I would have no reason to use iCal really, except that I want to sync my calendar info onto two iPods (touch and classic) to have that info with me on the go.
    Ideally I'd be able to input info onto either Google Cal or iCal and it would be reflected on the other one pretty seamlessly.
    Here's what I have now. Following directions from Google, I added my Google account to the "Accounts" page in iCal prefs using a link like this, "https://www.google.com/calendar/dav/[email protected]/user".
    Under the delegation tab I checked the various Google calendars that I want synced over to iCal. They all show up on iCal, so this part is working well.
    Unfortunately things start to head south here. If I'm not connected to the Internet, the various Google calendars display symbols because they can't connect. Fine. But when I try to sync the calendars through iTunes, nothing transfers. No events, no nothing. (I can't sync while connected to the 'net currently b/c I'm in a foreign country using a USB modem that blocks the other USB port. Hopefully I'll find a USB hub soon.)
    Anyway, two basic problems.
    1. Is there a relatively simple way to have two-way sync between iCal and Google Cal
    2. The issue with events not syncing to iPods

    Then check the following:
    1.) are you using the Mac OSX install DVD that came with this mac? Cuz only that would ensure to have the right windows drivers inside the windows port of the boot camp setup exe
    2.) Did you try to download the missing drivers via ID? there are several sites offering the right drivers by device ID (See device driver properties). To name one "Driveragent.com" but there is even a better one, but as its late here i really cant remember the name...
    But I get back to you on this one as soon as I hit my office again... promised

Maybe you are looking for

  • My iMac has booting weirdness

    OK to explain the situation and what I have done so far. My iMac has been working fine for ages then out of the blue 4 days ago instead of booting up it went to a grey screen with a tiny folder icon in the center of page with the finder logo on it. T

  • I just bought a macbook pro and asks me the password, says it has expired and I accept that I do?

    I just bought a macbook pro and asks me the password, says it has expired what I do?

  • Presario cq60 has stripes on screen when turned on

    HI , I have a Presario CQ 60 with Vista.  Two days ago when I turned it on, the screen was whitish with stripes.  I turned it off and started it again a minute later, and it was fine.  This is happening almost every day. I can turn it off during the

  • Two sided printing manually on 2540

    (mod added link: http://h30434.www3.hp.com/t5/Printer-All-in-One-Install-Setup/two-sided-printing-manually-on-2540/td...) Hello! I'm writing from Italy (there isn't an official forum in my language) I'm having the same problem but I can't solve becau

  • Currency Conversion- Urgent

    Hi Currency S_WAERS is in my selection screen. If i enter USD For S_waers the amount should convert to USD. If i leave blank it should  take local currency. Any one pls give me the coding for this. Thanks Kumar