Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Decode contact list from Nokia phone.

by ambrus (Abbot)
on Apr 05, 2016 at 21:03 UTC ( [id://1159650]=CUFP: print w/replies, xml ) Need Help??

The Nokia 6303c mobile phone can save a backup of the contact list (i.e. phone book) to the SD card. This node tells how to extract the list of contacts from such a backup to a human-readable file.

This description comes with no warranty. If you lose your contacts, you are on your own.

Note that the following procedure only saves the contacts from the phone memory. If you have contacts in the SIM card, you may have to copy those to the phone memory first.

Turn off your phone. Put an SD card into the SD card reader slot of the phone (you have to remove the battery cover for this, but you need not remove the battery). Turn on the phone. In the menu, choose Settings / Sync and backup / Create backup. You get a combo list where you have to choose what to backup, choose the entries you wish to backup (this CUFP is concerned only of the contact list). This will save a file to the SD card under a name like "Backup files/Backup015.NBF", where the "015" part of the filename varies so you can store multiple backups.

Turn off your phone, remove the SD card, and copy the files from the "Backup files" directory of the SD card to your PC with an SD card reader. (Alternately, you may be able to copy the file through an USB cable connected to the phone while the SD card is in your phone and it acts as a remote drive.)

Find the right backup among the files you have copied: this is usually the one with the latest mtime, provided the date on your phone was set up correctly. Suppose this file is called Backup015.NBF . The file is a zip archive. Unzip its contents to a directory called Backup015 with a command like 7z x -oBackup015 Backup015.NBF or with unzip Backup015.NBF -d Backup015 . You usually get a directory Backup015/predefhiddenfolder and possibly other directories.

Use the following command to dump the phone book information to a human-readable file. Note that the command argument Backup015 should be changed to the path of whatever directory you have extracted to. The path predefhiddenfolder/backup/WIP/32/contacts/ inside this appears to be fixed.

perl -e 'use warnings; use 5.016; use MIME::Base64; use Encode; use Un +icode::Collate::Locale; my$U=Unicode::Collate::Locale->new(locale=>"h +u"); my(@o,@u); for my$N (glob("$ARGV[0]/predefhiddenfolder/backup/WI +P/32/contacts/*.vcf")) { open my$C, "<", $N or die; my @r; while(<$C> +) { /\V/ or next; /\A([^:;]*)(?:;([^:]*))?:([^\n\r;]*)\r?\Z/ or do{wa +rn "ignoring in $N: $_"; next}; my($k,$e,$v)=($1,$2//"",$3); "ENCODIN +G=BASE64"eq$e and $v=decode_base64($v); "X-NOKIA-PND-GROUP"eq$k and $ +v=encode_utf8(decode("utf16le",$v)=~s/\0\z//r); if("BEGIN"eq$k||"VERS +ION"eq$k||"END"eq$k){next}else{my$b=("N"eq$k||"TEL"eq$k)?"":"$k=";pus +h@r,$b.$v} }; push@o,join(";",@r)."\n"; push@u,chr($r[0]=~/^\+/).$U-> +getSortKey(decode_utf8($r[0])); } print @o[sort {$u[$a]cmp$u[$b]} key +s@u];' Backup015 > cont.txt
This is an earlier version of the code.
perl -e 'use warnings; use 5.016; use MIME::Base64; use Encode; binmo +de STDOUT,":encoding(utf8)"; my@o; for my$N (glob("$ARGV[0]/predefhid +denfolder/backup/WIP/32/contacts/*.vcf")) { open my$C, "<", $N or die +; my @r; while(<$C>) { /\V/ or next; /\A([^:;]*)(?:;([^:]*))?:([^\n\r +;]*)\r?\Z/ or do{warn "ignoring in $N: $_"; next}; my($k,$e,$v)=($1,$ +2//"",$3); "ENCODING=BASE64"eq$e and $v=decode_base64($v); "X-NOKIA-P +ND-GROUP"eq$k and $v=encode_utf8(decode("utf16le",$v)=~s/\0\z//r); if +("BEGIN"eq$k||"VERSION"eq$k||"END"eq$k){next}else{my$b=("N"eq$k||"TEL +"eq$k)?"":"$k=";push@r,$b.$v} }; push@o,decode_utf8(join(";",@r)."\n" +); } print sort({fc$a cmp fc$b} @o);' Backup015 > contacts.txt

Check contacts.txt to see if it contains all the information you need. Some information may be missing, so be careful to check this file. In particular, the script doesn't currently print which telephone numbers are marked as what type (general, work, home, mobile, etc) and which of multiple phone numbers for a contact is marked as preferred (called automatically if you choose the contact in the contact list and press the dial button). If you need that information, modify the script.

That file should be utf-8 encoded and contain the names, phone numbers, and other contact information. The output is sorted, but it is sorted somewhat differently than the phone sorts it. Note though that I use a plus sign as a marker to sort certain names to the end of the contact list in my phone, so this script has special handling for that.

I will not give an example output, because my contact list is private. Sorry.

I know of no procedure to restore a contact list to the phone. As far as I've tried, the phone can't even load the backups it wrote itself.

Update 2018-11-06: see the next installment: Migrate phone numbers from Nokia 6303c to Nokia 216 then to CAT B30, or the quest for a sane phone.

Replies are listed 'Best First'.
Re: Decode contact list from Nokia phone.
by ambrus (Abbot) on Nov 08, 2017 at 14:21 UTC

    Tux recommends his perl module GSM-Gnokii for backing up a Nokia phone. That one can also restore contacts to the phone's phonebook, and get contacts directly from the SIM card. I haven't tried it yet.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://1159650]
Approved by choroba
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-16 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found