Clean up Picasa 3.9 contacts.xml with beginner perl commands at your friendly bash $ prompt.

So your Picasa 3.9 contacts are all messed up and you cannot edit some of them because they are linked to various google accounts. Next time, try to keep it clean by having email addresses for all your contacts. (Kamal even uses fake ones to help keep things linked, I don't go that far.) Valid email addresses will help Picasa 3.9 match your contacts up better as you switch from account to account. For now, take the power back and edit freely in Picasa offline, by logging out then removing all the links using the perl lines below:

#Get into your wine contacts folder:
cd "/home/USER/.wine/drive_c/users/USER/Local Settings/Application Data/Google/Picasa2/contacts/"

#Make a backup:
cp -a contacts.xml backup-contacts

#Remove all the "subject user" lines:
perl -n -i -e 'print unless /subject user|^$/;' contacts.xml

#Remove all the profile_photo_url tags:
perl -p -i -e "s/(profile_photo_url=\"([^\"])*\" )//g" contacts.xml

#Remove all the google_plus_id tags:
perl -p -i -e "s/(google_plus_id=\"([^\"])*\" )//g" contacts.xml

#Remove all the gaia_id tags:
perl -p -i -e "s/(gaia_id=\"([^\"])*\" )//g" contacts.xml

#Look what you did and clean it up more by hand if you like:
vi contacts.xml


Improve and simplify this if you like. These perl docs are really good:
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlrun.html
Mastering Regular Expressions, 3rd Edition
Other Picasa 3.9 Notes:
Picasa 3.9 added the option to store Nametags in the Metadata that is part of each photo file. No more lost tags when you copy JPG's elsewhere. Turn it on by Tools -> Options -> Name Tags -> Store Name Tags in Photo. Fix your old files with Tools -> Experimental -> Write Faces to XMP. This will take a long time as all your JPG files will be changed. Exif Viewer

1 comment:

Joel said...

I found this to be helpful. I also found a lot of junk emails in there. In order to get rid of them entirely, I had to go into the picasa3/cache/feeds/ directory for Picasa and delete the file that contained all of the contacts (email addresses, grep for them). I suppose in time the feed would have been updated, but I am impatient. :)