Librem 5 Can't import my VCF file using the the Contacts Importer script

Hello everybody!
I’m moving my first steps with the Librem 5… Right now I have all my contacts on a .vcf file exported from my android phone. I tried to follow this guide in order to import my contacts, but when I run the script I get the following error:
“File is not a vcard! Bye!”
But if I run the single command:
file --mime-type -b contacts.vcf
i get text/vcard, which is the correct output.
What am I missing?

Thanks in advance

make sure the text file has correct delimiters:

Begin:Vcard

contact info

End:Vcard

Begin:Vcard

contact2 info

End:Vcard

etc

Unfortunately the file command does the bare minimum to identify what type of file it is, usually only examining the first X bytes or Y characters, whereas a program that actually needs to consume a file may comprehensively validate the entire file.

In addition to checking the line ends (as suggested in the previous post?), check the VCARD version e.g. each entry in my VCF file, which did successfully import, has

BEGIN:VCARD
VERSION:4.0
:
:
END:VCARD

Edit: My .VCF file has “dos” line ends. That’s the way it exported from Thunderbird.

1 Like

Is there a Contacts exporter?

2 Likes

The problem is that this section of the script

MIMETYPE=$(file --mime-type -b $FILE)
CONTROL=“text/vcard”
if [[ “$MIMETYPE” != “$CONTROL” ]]; then
notify-send -t 1000 “File is not a vcard! Bye!” && exit 1
fi
should never send the notification “File is not a vcard”, because when i tried the file command on my .vcf file, it correctly outputted text/vcard.

Problem solved! The problem was that the file I was trying to import had a name with special characters in it, contacts (2).vcf
I renamed it to contacts.vcf and the import worked nicely!
Thanks :smile:

6 Likes

… one of my pet dislikes of shell programming. A script can seemingly work but then fail with such file names. Presumably needs more quoting. I would guess that the variable, FILE, is already not set correctly, so we would need to see more lines of the script. @joao.azevedo ?

2 Likes

@rekotc @irvinewade

Ok, I was late here. And I am sorry for that.

  1. Several things. The script in that article was modified over time and now lives in a package called librem5-goodies. And that can be installed from apt on a Librem 5. And it has had some updates since the article was originally written.
    And the script lives here: https://source.puri.sm/librem5-apps/librem5-goodies/-/blob/pureos/byzantium/l5-contacts-importer
    In any case I will check this case with the latest version

Yes, the latest version of the package Librem5-goodies has a script to dump all the contacts from the local address book into a vcard file or a csv, When you install the latest version of librem5-goodies there should be a single icon on the desktop that opens a window for you to choose if you want to import a contact list or export contacts.

  1. As soon as gnome-contacts 43 (which has support to import and export contacts as vcard) reaches byzantium, those scripts will likely be removed from the package librem5-goodies for being redundant.
1 Like

Thanks for replying. I didnt’ know about the librem5-goodies package, I’ve been tinkering with the phone since I got it on monday :smiley: So there are a lot of things I don’t know yet…
Anyway the original script worked :wink:
Thanks!

Yesterday morning my phone showed software updates having become available. Two of the three updates were for the Contacts application. After installing, I opened the Contacts, selected “Import” from the menu, and set up all my contacts from a vcf file that I had exported from another device a couple of weeks ago.

Yippee! Problem solved. No need for librem5-goodies or any other scripts or coding. Thanks to the developers for fixing this.

1 Like