![]() |
Convert all Contact Numbers
Hi
According to the ministry of communication in my country, All communications companies are changing all mobile numbers by adding a single digit to all numbers and I need a script to edit my contacts cuz I cannot edit them manually , it's impossible the script should do the following all numbers begininig with 011 or 014 or 0152 ... another 1 should be added after the first 1 so they become 0111, 0114 , 01152 and all 010, 016, 0151 should be 0100, 0106, 01051 and all 012, 018, 0150 should be 0122, 0128, 01250 can anyone even tell me how to write scripts .. I already have a good background in C/C++ programming because the deadline is this month !!!! or i wont be able to use the old numbers Thanks alooot |
Re: Convert all Contact Numbers
I think easiest solution is:
1. Export all contacts. 2. Concatenate all produced .vcf files to one long .vcf file containing all your contacts. 3. Using vi editor(or one of your choice) replace all numbers you want. 4. Re-import the edited multicontact .vcf file in your phonebook. No need of programming skills and will take 5 minutes. |
Re: Convert all Contact Numbers
So does that mean all the mobile phones in your country will not work at the end of the month ? What country are you in ? What part of the phone number are you referring to ? All new phones allows you edit numbers , unless I'm missing something!
|
Re: Convert all Contact Numbers
Quote:
Dear There is an APP. for this Prob it's "MeegoEgypt cotact Modifier" you can find it in STORE of N9 |
Re: Convert all Contact Numbers
Quote:
nice simple way :) but whats VI editor ? how can I make it edit all numbers in the vcf file ?? |
Re: Convert all Contact Numbers
Quote:
the first part of all numbers are edited because numbers are increasing and the 7 digit number isnt enough for the increasing mobile phones becides... to unify the first 3 digits for each of the three communication companies (all the first company customers will begin with 010 and the second will be 011 and third will be 012 ..) anyway there have been many android, BB, iOS and Nokia symbian apps for this issue but noone made an app for N900 :S and I cant edit 500 contacts manually man !! i.e: all phones in my country will work except mine :D |
Re: Convert all Contact Numbers
Quote:
|
Re: Convert all Contact Numbers
Quote:
|
Re: Convert all Contact Numbers
@sensortk
vi editor is text editor with text ui. Very powerful and widely used on *nix OS. It is very simle to do such substitutions once you have learned it. Here is an example. Let suppose the number you want to change is: +555 012 123 456 In .vcf line with that mobile number looks like this: Code:
TEL;TYPE=CELL:+55512123456 Code:
:%s/+55512/+555122/g You have to do this for all codes you want to change. |
Re: Convert all Contact Numbers
Does anyone managed to deal with that task ? I'm in the same situation... :( I need to add a "9" before every phone number that BOTH starts with 9 or 8 AND have 8 digits and wouldn't like to edit every each .vcf on a text editor. Does anyone wrote a script that i can adapt to my case ? i'd be eternally gratefull if someone share such piece of code.
|
Re: Convert all Contact Numbers
Quote:
Code:
grep -l ':+[89][0-9]\{7\}$' *.vcf | xargs sed -i '/:+[89][0-9]\{7\}$/s/\+/\+9/g' |
Re: Convert all Contact Numbers
I'd just sync the contacts to Outlook or similar, export them to an excel file, modify the information with functions or such and finally reverse the process to get the updates to the phone.
In fact, I think I have done that some time in the past. |
Re: Convert all Contact Numbers
Quote:
Code:
~/Exported contacts$ grep -l ':+[89][0-9]\{7\}$' *.vcf | xargs sed -i '/:+[89][0-9]\{7\}$/s/\+/\+9/g' And, yes, the .vcf files are in that folder. Am i missing something ? edit: busybox gives me another output: Code:
~/MyDocs/Exported contacts $ grep -l ':+[89][0-9]\{7\}$' *.vcf | xargs sed -i ' |
Re: Convert all Contact Numbers
Quote:
Thanks for the tip !!! |
Re: Convert all Contact Numbers
The command should be in one line with no breaks.
It's a combination of two commands: the grep lists all the files that match the pattern (regular expression) and hands them over to the sed, that does the find & replace part. If the grep doesn't find any files, it won't work. The pattern I used is: 1. a colon (:) 2. a plus-sign (+) 3. either 8 or 9 4. seven digits (from 0 to 9) 5. end of line ($) Maybe you find a pattern that works or you give me an anonymised vcf-file for testing purposes. |
I have a quick script for the br scenario. I look 4 it and post later.
|
Re: Convert all Contact Numbers
1 Attachment(s)
Quote:
Quote:
Quote:
|
Re: Convert all Contact Numbers
Quote:
|
Re: Convert all Contact Numbers
I see, there's no leading plus sign. Just remove it from the pattern in the grep command and in the sed command and it should work:
Code:
grep -l ':[89][0-9]\{7\}$' *.vcf | xargs sed -i '/:[89][0-9]\{7\}$/s/\+/\+9/g' |
Re: Convert all Contact Numbers
@saponga
Is this Code:
sed '/:[89][0-9]\{7\}\>/s/:/:9/g' -i *.vcf @obsidian there should be no need for xargs, or? $ did not work so I used \> |
Re: Convert all Contact Numbers
Quote:
|
Re: Convert all Contact Numbers
You are welcome.
obsidian was almost right: But/And I do also understand why the $ (end of line anchor) did not work but \> (end of word) does? |
Re: Convert all Contact Numbers
Recently I formatted all my numbers. The procedure used a small shell script and a sed script, and was run on the N9.
The steps are as follows: 0. make a backup and verify it works 1. clear the contacts dir 2. export all contacts to vcf files 3. run the script in the contacts dir 4. delete all contacts 5. reimport them as follows: in the contacts dir, do a "cat *.vcf > all.vcf" and import the all.vcf file. Here follows the scripts I used. First the shell script: Code:
#!/bin/sh Please test and adapt to your case before using on the device. Code:
# remove format chars |
All times are GMT. The time now is 01:08. |
vBulletin® Version 3.8.8