Reply
Thread Tools
Posts: 432 | Thanked: 917 times | Joined on Jun 2011
#21
Originally Posted by peterleinchen View Post
@saponga
Is this
Code:
sed  '/:[89][0-9]\{7\}\>/s/:/:9/g' -i *.vcf
what you are looking for ?
Woow \o/ Thank you very much !!! It worked like a charm.
 
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#22
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?
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature
 
Posts: 191 | Thanked: 415 times | Joined on Jan 2012
#23
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

# TEL;TYPE=CELL,VOICE:0118765-4321
for i in *.vcf; do
	sed -i -r -f 9th-digit-tim.sed $i
done
The sed script improves the number presentation, inserts the 9th digit and operator code.

Please test and adapt to your case before using on the device.
Code:
# remove format chars
/^TEL/	s/[\(\)\ \.-]//g
# cell phones of SP with 8 digits -> 0 41 DDD 9XXXX
/^TEL/	s/:(1[1-9])([6-9][0-9]{3})([0-9]{4})/:0 41 \1 9\2 \3/p
/^TEL/	s/:0(1[1-9])([6-9][0-9]{3})([0-9]{4})/:0 41 \1 9\2 \3/p
# cell phones without ddd
/^TEL/	s/:([6-9][0-9]{3})([0-9]{4})/:9\1 \2/p
# cell phone with ddd
/^TEL/	s/:([2-9][1-9])([6-9][0-9]{3})([0-9]{4})/:0 41 \1 \2 \3/p
/^TEL/	s/:0([2-9][1-9])([6-9][0-9]{3})([0-9]{4})/:0 41 \1 \2 \3/p
# non-cell phones
/^TEL/	s/:([2-5][0-9]{3})([0-9]{4})/:\1 \2/p
/^TEL/	s/:(1[1-9])([2-5][0-9]{3})([0-9]{4})/:0 41 \1 \2 \3/p
/^TEL/	s/:0(1[1-9])([2-5][0-9]{3})([0-9]{4})/:0 41 \1 \2 \3/p
 

The Following User Says Thank You to caveman For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 22:43.