Syncing iCloud contacts to Google Contacts

I’ve been looking for a way to sync my iCloud contacts to Google. Turns out that I already owned an app to do that and had forgotten about it:

I have it running on my Mac mini at Mac Stadium now, and it seems to work very well. The app says that it can do two-way sync, but I’ve set it up to only sync from iCloud to Google. It can run every 5 minutes or so, but I think hourly will suffice for my needs.

Anyway, there’s a small in-app purchase to make it work, but worth it in my opinion.

Whenever I talk about contacts on the Mac, I always have to mention Contacts Cleaner:

This app will spot any problems that might come about while syncing, I can’t say it will guarantee no-problems, but it will definitely reduce the issues.

Of course, it’s always a good idea to make a backup before you start doing anything with contacts. There are two options under “Export” in the “Contacts” app:

There are important differences between them:

  1. Export vCard… will export all of the contacts that are selected into a single vCard. So make sure you have them all selected if you want to back all of them up.

  2. Contacts Archive… will export all of your contacts but if you need to use this to restore, you will have to overwrite all of your current contacts.

My recommendation is to use the first option, and then look for a script which can “split” the vCard into individual cards. This one might do: vcard-split.py.

That way if you need to restore a single vCard from the mass export, you can do so.

The vCard file is mostly plain text, so it should compress well if you want to keep multiple copies.

Or, if you’re really adventurous, you could set up Keyboard Maestro or launchd to run this AppleScript every day/week/etc.

-- requires a folder "vCards" in ~/Documents/
--
set vPath to (path to the documents folder as string) & "vCards"
alias vPath

tell application "Contacts"
	repeat with cardPerson in people
		set nameOfvCard to name of cardPerson & ".vcf"
		set outFile to (open for access file (vPath & ":" & nameOfvCard) with write permission)
		write (vcard of cardPerson as text) to outFile
		close access outFile
	end repeat
end tell

That will make one-vCard-per-person in your ~/Documents/vCards/ folder (which you have to create first).

And, just for good measure, here’s an AppleScript that will save all of your contacts to ~/Documents/AddressBook.vcf

Once there, I’d recommend a Hazel rule to rename it with the current time & date or something like that.

set myBackupName to "AddressBook.vcf"

set myBackupPath to the (path to the documents folder as string) & myBackupName as string

-- To work on Mac OS X 10.4 - 10.7, change "Contacts" to "Address Book".
tell application "Contacts"
	
	-- Create an empty file
	set myBackupFile to (open for access file myBackupPath with write permission)
	
	repeat with per in every person
		write (vcard of per as text) to myBackupFile
	end repeat
	
	-- Close the file
	close access myBackupFile
	
	-- Quit the Contacts.app (which will be launched automatically when this script runs)
	quit
	
end tell

Well, that’s probably enough nerdity about contacts for one post!

2 Likes