Migrating Contacts over phones

Recently I was helping in a cell phone migration; contacts were the most important thing to migrate, but the devices where not directly compatible as the devices where a Nokia and a Samsung.

After a couple of Google’s searches, I got to the idea that there were no application so make my life easier, so I got to the task to investigate what the vendor’s applications were capable of.

I install in a Windows PC both suites, Nokia PC Suite and Samsung PC Studio, after I connect and synchronize both devices I got the option of exporting and importing contacts.

From the Nokia PC Suite, I exported all contacts; as a result I got a single file including all the 100+ contacts. I then turn to Samsung’s suite and try to import from the file, but it only imports the first one.

I don’t know if it has something to do with the vCard standard, but, most of the products I´ve tried do the same when reading multiple cards within a file.

So, next thing to do was to create as many files as contacts to import, wait a minute, this is more than 100 files!

What if I want to make a migration of a device with thousand of contacts?

To make my life easier, I start creating a DOS shell script to separate the file in as many contacts as is has. Its operation will be easy:
1. Read source file line by line
2. When detects the tag “BEGIN:VCARD” create a new file
3. Writes all read lines to the created file

Whit this simple process I got all the files I need and next step was to imported in Samsung’s suite. Fortunately, it support to drag-n-drop many files at a time, so, just in a moment the Agenda was introduced in the new phone.

Here is the code to create the vCards.

It reads the input file in the same path. File with contacts need to be named as “contacts.txt”


@echo off

set fileNumber=0

setLocal EnableDelayedExpansion
for /f "tokens=* delims==" %%a in ('type contacts.txt') do (
if "BEGIN:VCARD" == "%%a" (
set /a fileNumber+=1
echo BEGIN:VCARD > !fileNumber!.vcf
)
if NOT "BEGIN:VCARD" == "%%a" (
echo %%a >> !fileNumber!.vcf
)
)

goto :eof


Here you can find a copy of the script in case you want to test it yourself: readCards.zip

Comments

Popular posts from this blog

Before college

iPhone and the copy and paste programming

Initial development courses