this is not a complete export (i only needed the phone numbers) but it
might get you started.

On Sun, 2003-02-09 at 10:50, Peter L. Berghold wrote:
> Anybody out there have any scripts or C programs for exporting the
> Contacts list in Evolution?  
> 
> What I eventually want to be able to do is selectively export contact
> information and import it into an LDAP directory for shared contact
> info.
> 
> Thoughts anybody?
#!/bin/sh

export PATH DISPLAY
PATH=/home/hans/bin:/usr/bin:$PATH
DISPLAY=":0"

FILE="`/usr/bin/evolution-addressbook-export`"
cat $FILE | perl -e'

use strict;
my $line;
my $name;
my $tel_work_voice;
my $tel_work_fax;
my $tel_home;
my $tel_pager;
my $tel_cell;
my $tel_voice;
my $email;

while ( $line = <STDIN> ) {
	chomp ($line);
	chop ($line) ; # trailing ^M

#BEGIN:VCARD
	if  ( $line eq "BEGIN:VCARD" ) {
		$name = "";
		$tel_work_voice = "";	
		$tel_work_fax = "";
		$tel_home = "";
		$tel_pager = "";
		$tel_cell = "";
		$tel_voice = "";
		$email = "";
	}

#X-EVOLUTION-FILE-AS:
	if ( $line =~ /^X-EVOLUTION-FILE-AS\:.*/ ) {
		$line =~ s/^X-EVOLUTION-FILE-AS://g;		
		$name = $line;
		print $name." ";
	}

#TEL;WORK;VOICE;
	if ( $line =~ /^TEL;WORK;VOICE:.*/ ) {
		$line =~ s/^TEL;WORK;VOICE://g;
		$tel_work_voice = $line;
	}

#TEL;WORK;FAX;
	if ( $line =~ /^TEL;WORK;FAX:.*/ ) {
		$line =~ s/^TEL;WORK;FAX://g;
		$tel_work_fax = $line;
	}

#TEL;HOME;
	if ( $line =~ /^TEL;HOME:.*/ ) {
		$line =~ s/^TEL;HOME://g;
		$tel_home = $line;
	}

#TEL;PAGER;
	if ( $line =~ /^TEL;PAGER:.*/ ) {
		$line =~ s/^TEL;PAGER://g;
		$tel_pager = $line;
	}

#TEL;CELL;
	if ( $line =~ /^TEL;CELL:.*/ ) {
		$line =~ s/^TEL;CELL://g;
		$tel_cell = $line;
	}

#TEL;VOICE;
	if ( $line =~ /^TEL;VOICE:.*/ ) {
		$line =~ s/^TEL;VOICE://g;
		$tel_voice = $line;
	}

#EMAIL;INTERNET;
	if ( $line =~ /^EMAIL;INTERNET:.*/ ) {
		$line =~ s/^EMAIL;INTERNET://g;
		$email = $email.$line;
	}

#EMAIL;QUOTED-PRINTABLE;INTERNET;
	if ( $line =~ /^EMAIL;QUOTED-PRINTABLE;INTERNET:.*/ ) {
		$line =~ s/^EMAIL;QUOTED-PRINTABLE;INTERNET://g;
		$line =~ s/=0A/ /g; #=0A make it a space
		$email = $email.$line;
	}

#END:VCARD
	if ( $line eq "END:VCARD" ) {
		unless ( $tel_work_voice eq "" ) { print "wk=".$tel_work_voice." "; }
		unless ( $tel_work_fax eq "" ) { print "fx=".$tel_work_fax." "; }
		unless ( $tel_home eq "" ) { print "hm=".$tel_home." "; }
		unless ( $tel_pager eq "" ) { print "pg=".$tel_pager." "; }
		unless ( $tel_cell eq "" ) { print "cel=".$tel_cell." "; }
		unless ( $tel_voice eq "" ) { print "alt=".$tel_voice." "; }
		unless ( $email eq "" ) { print $email; }
		print "\n";
	}
}

' > /home/hans/bin/data/jpilot.txt
exit 0
rm -fr $FILE

Reply via email to