Sun, 16 Apr 2006

vcf to ezmlm

Just a real simple script for subscribing "Electronic Business Card attachment" vcard (.vcf) files into an ezmlm mailing list. Might save someone a bit of scripting. Doesn't like email addresses that have bash shell special characters.. fixing that is a excercise for the reader. No error checking.

#  really really simple script for dumping stuff from a vcf file into an ezmlm mailing list

import fileinput, sys, os

# split lines have format ['EMAIL', 'type=INTERNET', 'type=WORK', '\n']
# where they have the info we want

# takes VCF file and dir where the mailing list lives as the args

vcffile = sys.argv[1]
listdir = sys.argv[2]

command = "/usr/bin/ezmlm-sub %s %s"

for line in fileinput.input(vcffile):
    words = line.split(";")
    if len(words) == 4 and words[0] == 'EMAIL':
       email =  words[3].replace('type=pref:','',1).strip('\n')
       print "adding %s to list at %s " % (email,listdir)
       os.system(command % (listdir, email))

Posted at: 20:31 | category: /nerdy | # | 0 comments

posted comments -

post comment -





Secret Number Image