A command to convert text files into Address Book vCards

Sep 04, '03 08:15:00AM

Contributed by: bjast

Here's a Unix Terminal command to convert tab-delimited phone lists into a vCard format for importing into Apple's Address Book, or any other vCard application. The phonesample doc can be named anything, but the format must be:

Powells Books  [tab] 1-866-201-7601
Clark Lumbar   [tab] 503-692-0200
William Sonoma [tab] 1-800-541-1262
Note that there's simply a tab and no spaces between each of the above entries (spaces added above for readability). This command creates a 'Work' phone number. But that value can be changed to other acceptable phone titles: 'Mobile', 'Home,' etc. Here's the command:

awk -F\t ' {print "BEGIN:VCARD"; print "VERSION:3.0";  print "N:"$1; 
  print "TEL;type=WORK;type=pref:"$2; print "END:VCARD" $3; print $3 }' 
  sourcefile > newfile.vcf
The command is shown on three lines, but should be entered as one long line with a space replacing the two line breaks. Replace sourcefile with the path to the tab-delimited text file, and newfile.vcf with the name of the output file in VCF format. Make sure you use the .vcf extension, otherwise Address Book won't allow you to import the file.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030831221023355