Friday, July 27, 2012

An AppleScript to prevent the iCloud CRLF bug - normalize line endings

Yesterday I wrote perhaps the fifth AppleScript of my life, and I purged an iCloud paralyzing cloud of "Groups" created as a side-effect of iCloud's CRLF bug.

In the course of writing that brief AppleScript, I benefited from the extraordinary community built known as MacScripter. As I basked in my small victory against the uncaring forces of Appledom, I thought once again of fixing my Address Book's mixed CRLF/LF line terminations with AppleScript. I joined MacScripter and asked for advice.

In response,  Nigel Garvey wrote me a script. I suppose for him it was easier to write the solution than to try to explain it!

I ran it on my Snow Leopard primary address book (of course I made an archive backup). After a few seconds it returned "missing value". I've seen that when scripts complete, though it doesn't seem to be an ideal response.

In any case, I didn't see any evidence of windows style CRLF line terminators. When I exported test addresses as vCard they didn't show unexpected numbers of \n characters; though I continue to have some extra line feeds at the end of notes (but they seem to have LF terminations, not CRLF).

I took an exported archive and imported it into my Mountain Lion machine, then sent it to iCloud. I then viewed on my Lion machine. On all devices I see 1824 contacts and no duplicated notes. The only problem I came across were the extra LF at the end of notes, but they did not appear to be replicating. I think they are benign LF life feeds, not dangerous CRLF pairs.

I believe Mr Garvey's script worked. If you are one of the very few people who ever used MobilMe to sync Windows/Outlook and OS X/Address Book you should back up your Address Book, run this AppleScript, then confirm. Then consider migrating to the Cloud.

No comments:

Post a Comment