Sun, 16 Apr 2006
vcf to ezmlmJust 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.
#!/usr/bin/python # # 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', 'type=pref:firstname.lastname@example.org\n'] # where they have the info we want # takes VCF file and dir where the mailing list lives as the args vcffile = sys.argv listdir = sys.argv command = "/usr/bin/ezmlm-sub %s %s" for line in fileinput.input(vcffile): words = line.split(";") if len(words) == 4 and words == 'EMAIL': email = words.replace('type=pref:','',1).strip('\n') print "adding %s to list at %s " % (email,listdir) os.system(command % (listdir, email))