Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A command to convert text files into Address Book vCards UNIX
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.
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[14,667 views]  

A command to convert text files into Address Book vCards | 4 comments | Create New Account
Click here to return to the 'A command to convert text files into Address Book vCards' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A command to convert text files into Address Book vCards
Authored by: iordonez on Sep 04, '03 04:52:11PM

How would this be used to Create a file with Names and E-mail addresses?



[ Reply to This | # ]
A command to convert text files into Address Book vCards
Authored by: logo on Sep 05, '03 04:22:18AM

That would be extremely useful.

Any good source to get info on even more fields?

I'm not really willing to pay big $$ for one of the few small utilities that would convert my 50 or so addresses!

Thank you in advance!



[ Reply to This | # ]
A command to convert text files into Address Book vCards
Authored by: pdowling on Sep 05, '03 07:40:46AM

Use the Address Book app to create an address card with all fields filled out. Drag it to the Desktop and open with TextEdit. You can then see all of the tags that are used.



[ Reply to This | # ]
A command to convert text files into Address Book vCards
Authored by: webentourage on Sep 05, '03 03:56:00PM
All you have to do is use the awk code I've modified below, and add another tab field to the text file with the email address.

eg: name [tab] phone [tab] email

awk -F\t ' {print "BEGIN:VCARD"; print "VERSION:3.0"; print "N:"$1; print "EMAIL;type=WORK;type=pref:"$3; print"TEL;type=WORK;type=pref:"$2; print "END:VCARD" $4; print $4 }' infile.txt > newfile.vcf

[ Reply to This | # ]