Friday, 22 November 2019

Import Google contacts into abook

abook screenshot
Abook is simple text based address book that works well with Mutt

I’ve been trying to figure out how to import Google contacts into abook for awhile. I was repeatedly disappointed that I couldn’t find any useful and up-to-date instructions or scripts. It turns out that abook is way more powerful and configurable than I thought. The answer was right in front of me the whole time.

One article that I read was about importing your Outlook contacts into abook format and short Ruby script and a couple of terminal commands. It didn’t work properly for me, but it reminded me of something I should have checked first. That’s right. The man page. Duh.

$ man abook

That told me that I could use abook itself to import from several common contact file types including .vcf. Aha! Google contacts will let you export directly to the standardized vCard format! Go to contacts.google.com, select the contacts that you would like to export, click Export on the left and save to a .vcf file. Then, at the command line, enter:

$ abook --convert --informat vcard --infile ~/Downloads/contacts.vcf --outformat abook --outfile addressbook1

I saved the new addressbook file to addressbook1 because I already had a small addressbook and didn’t want to overwrite it. Unfortunately, I didn’t readily find a was to merge the files since the format includes an “id” number. That’s pretty much it to import Google contacts into abook. Super easy. It’s no wonder it was difficult to find specific instructions and/or scripts. Abook already does it!

To further customize abook, copy the example config from /usr/share/doc/abook to ~/.abook/abookrc and play around. I added a Note field on the Other tab to include notes about how I know the person. Anyway, I hope this simple guide helps and reminds you not to forget about man pages!