To convert a vCard addressbook to the fritzbox xml format I wrote this short perl script.

 

#!/usr/bin/perl -w
use warnings;
use strict;

my $inputFile = shift;

open(VCARD, $inputFile);

my $newContactFlag = 0;
my %nameNumberHash;
my $name;
my $i = 0;

# Input section

sub umlautwechseln {
    my $messystring = shift;
    my $conversion = shift || "1";
 
    my @vorlage = (
        [   'ä',   'ö',      'ü',      'Ä',      'Ö',     'Ü',      'ß'],
        ['ä', 'ö', 'ü', 'Ä', 'Ö','Ü', 'ß'],
        [   'ae',  'oe',     'ue',     'Ae',     'Oe',    'Ue',     'ss']
    );
 
    for (0 .. 6) {
        $messystring =~ s/$vorlage[0][$_]/$vorlage[$conversion][$_]/g;
    }
 
    return $messystring;
}

while(<VCARD>)
{
        if($_ =~ /^FN:(.+)\n$/)
        {
            $name = $1;
            chop($name);
            $name = umlautwechseln($name);
        }
        elsif( $_ =~ /TEL;type=(.+);type=VOICE:\+49(\d+)/ )
        {
            $i++;
            my $type = lc($1);
            $nameNumberHash{$name} .= "<number type=\"$type\" vanity=\"\" prio=\"1\">0$2</number>\n";  
        }
        elsif( $_ =~ /TEL;type=(.+);type=VOICE;type=pref:\+49(\d+)/ )
        {
            $i++;
            my $type = lc($1);
            $nameNumberHash{$name} .= "<number type=\"$type\" vanity=\"\" prio=\"1\">0$2</number>\n";  
        }
}

close(VCARD);

# Output Section

print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
<phonebooks>
    <phonebook>";
my $id = 0;
foreach my $key ( keys %nameNumberHash )
{
    my $name = $key; # chop($key);
    #print "key: $key, value: $nameNumberHash{$key}\n";
print"        <contact>
            <category>0</category>
            <person>
                <realName>".$key."</realName>
            </person>
            <telephony>
                $nameNumberHash{$key}
            </telephony>
            <services />
            <setup />
            <mod_time>1319558289</mod_time>
            <uniqueid>$id</uniqueid>
        </contact>";
    $id++;
}
print "    </phonebook>
</phonebooks>";

After that you can start it with:

perl vcards2fritz.pl vCards.vcf > test.xml

and you can upload the test.xml file to your fritzbox.

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.