Skip to content

Instantly share code, notes, and snippets.

@itaysk
Created April 13, 2021 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itaysk/4e1091bacb2b9d44d37a9b9274217576 to your computer and use it in GitHub Desktop.
Save itaysk/4e1091bacb2b9d44d37a9b9274217576 to your computer and use it in GitHub Desktop.
Outlook CSV to VCF
#! /usr/bin/env gawk -f
# convert contacts exported from Outlook.com to VCF (vCard)
BEGIN { FS = "," }
{
print ""
print "BEGIN:VCARD"
print "VERSION:3.0"
print "KIND:individual"
}
{
print "FN:"$1 $2
print "N:"$3";"$1";"$2";;"
}
$6 {
print "NICKNAME:"$6
}
$12 {
print "TEL;VALUE=uri;TYPE=home:"$12
}
$14 {
print "TEL;VALUE=uri;TYPE=business:"$14
}
$16 {
print "TEL;VALUE=uri;PREF=1;TYPE=cell:"$16
}
$9 {
print "EMAIL;PREF=1:"$9
}
$10 {
print "EMAIL;type=OTHER:"$10
}
$30 {
print "TITLE:"$30
}
$32 {
print "ORG:"$32
}
$43 || $44 || $45 || $46 || $47 {
print "ADR;type=HOME:;;"$43";"$44";"$45";"$46";"$47
}
$38 || $39 || $40 || $41 || $42 {
print "ADR;type=WORK:;;"$38";"$39";"$40";"$41";"$42
}
$39 {
print "NOTE:"$39
}
{
print "END:VCARD"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment