Ah, yes. One of those projects that I just knew would be simple.

The Nokia 2705 Shade is an extremely basic flip phone, and it’s what my father used until this year. Since it was released in 2009, it does have Bluetooth, and contacts can be shared via exactly one mechanism: Bluetooth file exchange. This mechanism makes it possible to keep contacts while switching to a more modern smartphone, but there are a few stumbling blocks.

The first problem is that iPhones don’t support Bluetooth file exchange. (Maybe this would be supported on Android, I’m not sure.) I was able to work around this by sending the contacts to my Windows 10 PC instead, but there is a catch there, too: you must pair the phone while receiving the files. If the receive screen in Windows 10 is not open while pairing the phone, the PC will not advertise its file exchange capability to the phone. Then the phone caches this information, so it will never try to send the file. But as long as you pair the devices during the actual file-receive process, everything works fine.

The result is a directory full of vcf files, one per contact. At this point, I thought I was home free. But iCloud.com wouldn’t open these files – and even if it had, I found that it wouldn’t accept more than one file at once. I wasn’t looking forward to uploading over 60 files individually.

I found that the following changes had to be made for iCloud to read the files:

  • The files had Windows line endings, but Apple wanted UNIX line endings. I just ran dos2unix on all the files.
  • The phone had generated vCard files with VERSION:2.1 version strings; I replaced this with VERSION:3.0 in each file.
  • The phone had generated names in the format N:John Doe – as far as I can tell, this is incorrect. iCloud required two lines:
    FN:John Doe

After these changes, iCloud accepted the files.

Here is the horrible script I used to fix the files; please do not use it:
mkdir done
for x in *.vcf; do
dos2unix $x
ON="$(grep -E '^N:' $x)"
FIRST="$(echo "$ON" | cut -d ':' -f 2 | cut -d ' ' -f 1)"
LAST="$(echo "$ON " | cut -d ' ' -f 2 | cut -d ' ' -f 1)"
grep -EB999 '^N:' $x | sed -e 's/^N:/FN:/'
echo "N:$LAST;$FIRST;;;"
grep -EA999 '^N:' $x | tail -n +2
) > done/$x
I already know for sure that this script mangles entries that have three names (like “Billie Joe Armstrong”), though it does work with single names (like “Madonna”). I just manually fixed the entries which had three names.

One nice thing I discovered is that, once you have the fixed files, you can concatenate them (for example, cat *.vcf > complete.vcf) to generate a single VCF file with all the contacts. Then, iCloud will accept the single file, but import all the contacts at once. Success!