0

Is it possible to export macOS Contacts with Groups?

Exporting All Contacts seems to create a flat file with all contacts and does not populate the CATEGORIES: property.

1 Answer 1

1

I wanted to import my Contacts into a webmail client roundcube in Cpanel on my server.

I wrote a script which partially works.
It successfully allows the resultant to be imported into roundcube but does have some limitations, viz. if a contact already exists it is missed with error "Skipped 1 existing entries:" so this fails for contacts in more than 1 group.

The following script takes a .vcf file produced by exporting a Group from Contacts then inserts CATEGORIES.

#!/bin/bash

# insert CATEGORIES: into .vcf file
# CATEGORIES is derived from file name
# 2022-04-23

if [ $# -eq 0 ] ; then
    echo 'Enter vcf file name on command line'
    exit
fi
CATEGORY=$1

# copy sed script to a temporary file
cat << EOF > /tmp/sedscr
/END:VCARD/i\\
CATEGORIES:$CATEGORY
EOF

VCF_FILE="$CATEGORY.vcf"

# Check/create Backup VCF File
if [ ! -e "$VCF_FILE.orig" ]; then
    cp "$VCF_FILE" "$VCF_FILE.orig"
fi

sed -f /tmp/sedscr "$VCF_FILE" >/tmp/vcffile

# copy modified files from /tmp
cp /tmp/vcffile "$VCF_FILE"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .