maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   Convert all Contact Numbers (https://talk.maemo.org/showthread.php?t=83052)

saponga 2014-05-01 20:51

Re: Convert all Contact Numbers
 
Quote:

Originally Posted by peterleinchen (Post 1423735)
@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 2014-05-01 20:56

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?

caveman 2014-05-02 19:40

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

# 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



All times are GMT. The time now is 10:56.

vBulletin® Version 3.8.8