Posts Tagged ‘Python’

Sony Ericsson W705 Renumbering

Posted: October 8, 2011 in Technical
Tags: ,

Like all Egyptians, I had to modify all my phone book to be in-sync with the new numbering domains. First of all I tried to download the tool provided by Vodafone Engezly, After installation I ran the phone book updater, and I got a very nice message “No Contacts Need To Be Changed” :D.

A friend told me about some desktop “Windows” tool to do the job, “EgyMobiED“, I followd the steps and after some hassle I managed to backup my contacts using Windows 7 Bluetooth devices, and searched my disk till I found where does Windows 7 store them(*.VCF format files) for further Restore operation.

I tried EgyMobiED and it did the job well, Now I have to get them back to my mobile, I deleted all my contacts using Sony Ericsson PC Companion Phone Contacts tool, and tried to restore the contacts using Windows 7 Bluetooth Devices Restore Backed-up contacts and found that I have to accept each contact on my mobile (pressing accept and minimize per each contact) and I have 385 one ! :S, Moreover it failed multiple times  and I had to restart the operation and uncheck the restored contacts, So it was just like a nightmare!

I googled and found some Sony Ericsson tool called Sync Phones which requires Windows Contacts (*.CONTACT format files), So I imported my *.VCF files into Windows Contacts, and smoothly synchronized my  mobile with Windows Contacts.

Now I have all my contacts again on phone, But I found a new problem!!! 😀

My problem was historical to some extent, Since I migrated from Nokia mobile 2 years ago using the same technique (Windows 7 Bluetooth Devices tools), the imported contacts was in that format:


The Number filed was like that (TEL:0123456789), which Windows Contacts did not recognize in importing from VCF format to CONTACT format .

So I had to replace all my VCF contacts to Windows Contacts recognizable format by replacing all “TEL:” with “TEL;CELL”, So it is time for Python 😀

I quickly wrote this snippet and managed to convert my number field to recognizable one and re-synchronized my phone again, and IT WORKS 😀

Created on Oct 8, 2011

@author: arefaey
import os
src = '/home/arefaey/Desktop/src'
dest = '/home/arefaey/Desktop/dest'
inputs  = os.listdir(src)
outputs = os.listdir(dest)
for contact in inputs:
    f = os.path.join(src, contact)
    f = open(f, 'r')
    o = os.path.join(dest, contact)
    o = open(o, 'w')
    for line in f.readlines():
        line = line.replace('TEL:', 'TEL;CELL:')
    print 'Contact : %s is done' % contact

Now all contacts turned into this format:


For sure I had some victims when a VCF file contains both “TEL:” and “TEL;CELL:” so after refactoring I had duplicate CELL fields and the mobile just recognized the first, isA I will implement a new snipped to resolve this issue :D.

Thanks Ayman for your nice tool.