My calendar has been a mess for a while – or rather, the organisation of calendars. For years I’ve had several devices and keeping them in synchronisation was a nightmare – from my original Palm Vx handheld right up to the iPad and iPhone I now use it’s been tricky, not helped by absence of decent CalDAV software or support for calendar servers on the devices I’ve used. Add into the mix almost 20 years of historic calendar data (where sometimes I do need to find the last time I saw a particular client for instance) and it’s a recipe for disaster.

When Apple released MobileMe it got a bit better. Around 2004ish I managed to export my calendar from the Palm software using Missing Sync and into iCal, and thus into MobileMe. Through that I frigged it to talk to my phone at the time, a Nokia E70 (I think). Then when iCloud came along I ported it and my iPad, iPhone, Mac and the web stuff was all integrated. Hoorah.

Then this week it all went tits-up. I decided to merge two work calendars so Nicky could share them, by exporting both calendars as ICS files and then importing them into a new calendar. Of course, connectivity at a client’s this week has been very flakey as they’re moving offices and iCloud seemed not to like this when it attempted to sync the new entries which manifested itself as the iCal client app giving me 403 errors (“UID already exists”). No amount of Googling and buggering about with Apple Support would fix it so I took matters into my own hands.

Problem 1 – Getting the calendar entries in without having to retype 20 years of historical data: the ICS ‘UID’ field on iCloud is unique to the group of calendars it seems, which are grouped under one username. The solution was to export the ICS file (without connectivity, so iCloud didn’t attempt to be clever) and run a small perl script which would append “JFIX-” to the UID and then re-import. This then gave me a new calendar with new entries, which I could then sync with iCloud (it took about an hour for it to stop ‘Updating…’). So far so good, but after an hour I discovered…

Problem 2 – events appearing in iCloud and iCal don’t propogate to iPad or iPhone: Turns out that UID needs to be hexadecimal for it to work properly, so I re-ran my perl script to append ‘ABCD-‘ instead. This createdanother set of UIDs which I could import into a new calendar. This worked fine, and has propagated to all my iDevices.

In Googling this by the way I found a series of touted solutions, one of which was to use grep to remove UID lines altogether. iCloud really hates this and goes on a duplication fest, adding in events sometimes up to 15 times (but most likely adding between 5 and 10). I also worked out after a while that the easiest way of finding out what’s really in iCloud is to look on the web client, as this is what gets sent to the phones, iPads, etc. If it’s not there, it’s not going to propagate or be visible.

Lesson learned though is: (a) be prepared for a nightmare if you want to en-masse move events from one calendar to another, and (b) make sure your connectivity is rock-solid and don’t be impatient.