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)

Obsidian 2014-04-30 13:54

Re: Convert all Contact Numbers
 
Quote:

Originally Posted by saponga (Post 1423479)
Does anyone wrote a script that i can adapt to my case ?

Try this in the folder where your vcf files are:
Code:

grep -l ':+[89][0-9]\{7\}$' *.vcf | xargs sed -i '/:+[89][0-9]\{7\}$/s/\+/\+9/g'
I'm not sure if I installed sed from the repositories or if it's part of maemo anyway. So If sed is not found, you'll have to install it.

Aonsaithya 2014-04-30 13:57

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.

saponga 2014-04-30 14:23

Re: Convert all Contact Numbers
 
Quote:

Originally Posted by Obsidian (Post 1423491)
Try this in the folder where your vcf files are:
Code:

grep -l ':+[89][0-9]\{7\}$' *.vcf | xargs sed -i '/:+[89][0-9]\{7\}$/s/\+/\+9/g'
.

Thanks bro... I did try it on my kali box but:
Code:

~/Exported contacts$ grep -l ':+[89][0-9]\{7\}$' *.vcf | xargs sed -i '/:+[89][0-9]\{7\}$/s/\+/\+9/g'
sed: no input files

I should try to debug your line but i really didn't understand anything :)
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 '
/:+[89][0-9]\{7\}$/s/\+/\+9/g'
sed: -i requires an argument

Thanks again buddy !!!

saponga 2014-04-30 14:31

Re: Convert all Contact Numbers
 
Quote:

Originally Posted by Aonsaithya (Post 1423492)
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.

That is a good idea... Although i'll wait and see if someone has already managed to solve that situation using (b)ash. :)
Thanks for the tip !!!

Obsidian 2014-04-30 22:31

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.

caveman 2014-04-30 23:51

I have a quick script for the br scenario. I look 4 it and post later.

saponga 2014-05-01 00:48

Re: Convert all Contact Numbers
 
1 Attachment(s)
Quote:

Originally Posted by Obsidian (Post 1423564)
The command should be in one line with no breaks.

Well... i just did a copy/paste... :confused:
Quote:


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 ($)
Thanks for your patience. I'll try to understand that line for sure.

Quote:

Maybe you find a pattern that works or you give me an anonymised vcf-file for testing purposes.
Thanks again. I'm attatching a .vcf file.

saponga 2014-05-01 00:49

Re: Convert all Contact Numbers
 
Quote:

Originally Posted by caveman (Post 1423578)
I have a quick script for the br scenario. I look 4 it and post later.

I'll really apreciate that. Thanks.

Obsidian 2014-05-01 08:05

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'

peterleinchen 2014-05-01 19:56

Re: Convert all Contact Numbers
 
@saponga
Is this
Code:

sed  '/:[89][0-9]\{7\}\>/s/:/:9/g' -i *.vcf
what you are looking for?

@obsidian
there should be no need for xargs, or?
$ did not work so I used \>


All times are GMT. The time now is 21:52.

vBulletin® Version 3.8.8