Convert GoogleCL gmail contacts to cone adress book

google contacts list name,name,email|perl -pne 's%^((?!N\/A)(.+?)),((?!N\/A)(.+?)),([a-z0-9\._-]+\@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+))%${1}:${3} <${5}>%imx' #see below for full command
Full Command: google contacts list name,name,email|perl -pne 's%^((?!N\/A)(.+?)),((?!N\/A)(.+?)),([a-z0-9\._-]+\@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+))%${1}:${3} <${5}>%imx'|grep -oP '^((?!N\/A)(.+?)) <[a-z0-9\._-]+\@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+)>' | sort You'll need googlecl and python-gdata. First setup google cl via: google Then give your PC access google contacts list name,email Then do the command, save it or use this one to dump it in the cone-address.txt file in your home dir: google contacts list name,name,email | perl -p -n -e 's%^((?!N\/A)(.+?)),((?!N\/A)(.+?)),([a-z0-9\._-]+\@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+))%${1}:${3} <${5}>%imx' | grep -o -P '^((?!N\/A)(.+?)) <[a-z0-9\._-]+\@([a-z0-9][a-z0-9-]*[a-z0-9]\.)+([a-z]+\.)?([a-z]+)>' | sort > ~/cone-adress.txt Then import into cone. It filters out multiple emails, and contacts with no email that have N/A. (Picasa photo persons without email for example...)
Sample Output
Contact One: Contact2 <[email protected]>
Contact Two: Contact2 <[email protected]>

What Others Think

+1 for GoogleCL. For those who haven't heard of it, GoogleCL allows command-line access to your Google Apps. Very useful. http://code.google.com/p/googlecl/
StefanLasiewski · 520 weeks and 5 days ago
You can also do it with the abook: data=name,email,phone,address,im,company,notes; (echo $data; google contacts list $data) | abook --convert --informat csv --outformat abook --outfile ~/.abook/addressbook
matthewbauer · 520 weeks and 4 days ago
googlecl no more works since google has update is auth service from OAuth1 to OAuth2 :(.
rcspam · 239 weeks and 5 days ago
When the writers are working on Religion and Theology Writing Services, they have to ensure they conduct thorough Religion and Theology Research Writing Services on the topic areas in order to complete the best Custom Religion & Theology Research Paper using recent sources.
florahwilliams · 19 weeks and 2 days ago
WritePaperFor.Me is the best site here . You’ll provide even the most challenging papers by the deadline .
TomNill · 10 weeks and 4 days ago
There are a multitude of resources available for a wide variety of industries looking to hire freelancers. Field Engineer is a well-known global marketplace, where you can hire engineers and technicians to assist your workforce
kotifield · 6 weeks and 1 day ago
Nice concept, briefly described, and helpful for website content writing help for beginners like me to learn new things and unique content. Good work!
RidaHashmi · 5 weeks and 2 days ago
I think this site https://soclikes.com/ is good to buy tiktok likes
soclikes · 2 weeks ago
I think this site https://soclikes.com/ is good to buy tiktok likes
soclikes · 2 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: