Schlagwort-Archive: vcf

How To Import VCF (VCard) in Ubuntu Touch

This sounds unbelievable, but is indeed true: You cannot import a .vcf file into Ubuntu Touch in 2016 – three and a half years after the first version of the OS was published!

This AskUbuntu thread is one of the only results – but it doesn’t work with .vcf files containing multiple contacts.

I botched together this little script, that splits up your VCard file and imports each contact into Ubuntu Touch.

You can run this using the Terminal App from the Ubuntu store / OpenStore or via adb shell from your computer. Connect your phone via USB and enable Developer Mode.

#!/bin/bash -e

# Ubuntu Touch import script for VCard Files, public domain.
# First parameter is file to be imported (e.g. `./import.sh my_contacts.vcf`)
CONTACTDB="Personal" # change this to Persönlich if device language is German

awk ' /BEGIN:VCARD/ { ++a; fn=sprintf("card_%02d.vcf", a); print "Writing: ", fn } { print $0 >> fn; } ' $1

for $VCARD in card_*
do
	echo "Importing: ${VCARD}"
	syncevolution --import ${VCARD} backend=evolution-contacts database=${CONTACTDB}
	rm ${VCARD}
done

You might have to change the variable $CONTACTDB to suit you language. The correct term can be found when clicking the gear icon in the Contacts app.

The awk command comes from this StackExchange thread – no copyright claimed.