I got myself a new Smartphone with Android 2.0 and wanted to transfer all my Contacts and SMS from my old WM6 - without Google.
First the contacts: To transfer contacts, there is a wonderful standard called vcard. The android address book is able to import .vcf (vcard) files from the telephones sd card and WM6 can create a vcard if you send a contact via bluetooth. But there are three problems: 1. Android can't receive contacts via bluetooth, 2. WM6 can only send one contact at once, so it's no fun if you have more than 20 contacts and 3. the vcard implementation of WM6 is not correct, so that contacts exported like this can't be imported by android.
So the solution to export the contacts from the WM6 phone is the very good program PIM Backup, which I already used to backup the phone. The app stores its backups in a zip-compressed file, in which the data is stored in a plain text file. For each contact you have a new line and the values are stored separated with semi-colons.
I wrote some code in perl to convert the backup file to multiple vcard files, one for each contact. After this i just copied these files to the Android sd-card and used the contact import function.
Contact pictures are not supported, but feel free to extend and/or rewrite the code!
The second thing are the SMS: I again used the PIM Backup application to export the SMS, because WM6 has no solution to export SMS. The file structure is like the one from the contact backup, one line for each message, fields are separated with semi-colons. But this time there is a field with the message text inside and it the text contains a line break you'll have one in the backup file too. I edited the file with vim and its string substiturion function to replace line breaks in the message text with the string <BR>. In the perl script later on it will be replaced again to a line feed.
Now we have the input data, but how can we import it into the Android SMS software? There is no import function in the application itself, but there is a backup software for SMS in the Android Marketplace called SMS Backup & Restore. This app stores its backup in a very neat XML file called sms.xml.
My perl code now converts the backup file from the WM6 phone to the sms.xml format. All you have to do is replace the sms.xml on the sd-card with the generated on and restore it with the Android application. Et voila, all SMS are on the Android phone and it looks like you had received all the messages with this phone :-)
Hi, great article. I successfully got my 11,500 messages from my old WiMo phone. I had to tweak the Perl source code, though. You can read about my experience and download the updated source code from here: http://www.lewisoaten.com/2009/01/20/mobile-data-preservation.html
VeryAndroid SMS Backup is a smart andriod sms backup software that can copy and backup sms on Android phone to computer, restore sms backup file to any android phone, and also send messages or chat with a friend on computer directly, exactly the same as that you do on your android phone.
It can help you:
- Copy and backup sms from Anroid phone to computer.
- Restore sms from CSV to android phone any time.
- Send SMS & SMS Chat on computer directly.
- Transfer sms to android phone from other phones (iPhone, Windows Mobile, Nokia, Blackberry etc).
- View sms messages in threading mode on computer.
Thanks for the how-to. just got my android phone and want to move all smses from my old HTC phone.
on running your script, I got these error:
Argument "\01\02\0" isn't numeric in subtraction (-) at ./PIM2smsxml.pl line 30, line 2.
Argument "\02\00\00\09\0" isn't numeric in integer ge (>=) at /opt/local/lib/perl5/5.8.8/Time/Local.pm line 103, line 2.
Month '-1' out of range 0..11 at ./PIM2smsxml.pl line 30
what do I miss? Thanks for your great how-to and help.
I have perl 5.8.8 on Mac OsX.
I had exactly the same problem. What worked for me was to follow the instructions given at:
It creates the xml file and you can filter out messages that you don't want anymore. It's excellent!!
Had problems with the other methods (don't know much about perl or python) and this post solved everything!
Thanks for taking the time to put the code/notes together. I've installed PIMBackup on my WM6 phone and been able to run it fine for my contacts. When you ran it, did you select the "Compress Backup" and "Binary backup (faster)" check-boxes, or not?
Also, I'm having what I'm sure is just a silly problem - I can't seem to unzip (using gunzip on ubuntu) your perl code. What did you use to compress it?
Any thoughts would be most appreciated.
The code is only tar'ed. Not Gzipped as well. To get it ready to run, use "tar xvf PIM2smsxml.tar.gz" not xzvf as you're expect.
Otherwise, this is great. Very easy to get my texts into Android.
The process to make the source file ready in VIM could've been better explained.
I ended up opening and closing the file in gedit to have it "convert" to the correct format. Then, ":%s/\r//" to remove all the ^M. Then, ":%s/""\n/""/g" to replace the enf of line with a place holder. Then ":%s/\n//g" to kill all other . Finally, ":%s//\r/g" to get us one where we need it.
Hope that helps someone save a little time.
thanks for the script and the guidance.
first,sorry for my bad English.
Can u tell me how to use your perl code for converting .pib file to .xml file ?!
Thanks for the guide. I'm struggling to get it working though for my SMSes. I have used PIMbackup to create the PIMBackupxx.pib file and extracted the file msgs_xx.pbm from that. I then installed ActivePerl 5.10.1 Build 1007 and ran pim2smsxml.pl from the command line as follows:
(I renamed the files for ease of use)
however, i get the following errors:
Use of uninitialized value $data in substitution (s///) at C:\a\p2s.pl line 2
2, line 2.
Use of uninitialized value $MSG in substitution (s///) at C:\a\p2s.pl line 27, <
DATA> line 2.
Use of uninitialized value $MSG in substitution (s///) at C:\a\p2s.pl line 28, <
DATA> line 2.
Use of uninitialized value in split at C:\a\p2s.pl line 29, line 2.
Use of uninitialized value $DATE in subtraction (-) at C:\a\p2s.pl line 30, <
DATA> line 2.
Use of uninitialized value $year in integer ge (>=) at C:/Perl/lib/Time/Local.pm
line 94, line 2.
Use of uninitialized value $year in integer lt (=) at C:/Perl/lib/Time/Local.pm
line 97, line 2.
Use of uninitialized value $year in integer gt (>) at C:/Perl/lib/Time/Local.pm
line 98, line 2.
Month '-1' out of range 0..11 at C:\a\p2s.pl line 30
However I don't know how Perl works, so i'm a bit stuck now...
I am using Windows XP SP3 in the UK with the date set in the format dd/mm/yyyy if that is any assistance.
Thanks for the guide. but I still experience difficulties in restoring both the contacts and sms. after I run the "PIM Backup v2.8" on my WM6.5, it's not creating a .zip file but .pib file (size around 250 KB for about 780 contacts). I have transfered all the file (your perl code and .pib) the file to my sony ericsson X10 (Android 1.6) and run the "import contact", but it said no contact to restore.
Could you please tell me what should I do about it? I really need a solution desperately.
Thank you for your kind attention.
For me it's not working the Perl script,but i dont know if i have the correct output and how the Hell do a replace the line break, what is it a space or what character is it ?????????
Please help me.
ok, PIM Backup isn't in plain text so this didn't work for me.
I am a neewbee in perl!
How can I use Your script to convert the PIMBackup file?
Please, oh please, give me a clue how to use the perl code that you're written to convert SMS messages! I'm not seeing how to point it toward the file that I want it to convert and running it seems to have no result other than the generation of an otherwise empty .xml file.
Any assistance would be deeply appreciated.
I have tried the described solution, but the perl code does not work for me. I am getting some uninitialized variable errors on my ubuntu. Can you fix that?
i can't make your script work. it says me : i've extracted the smses from pimbackup. can you help me ?
thomas@iskra:~$ perl PIM2smsxml.pl msgs_20101102.csm
Argument "\01\02\0" isn't numeric in subtraction (-) at PIM2smsxml.pl line 30, line 2.
Argument "\02\00\00\07\0" isn't numeric in integer ge (>=) at /usr/share/perl/5.10/Time/Local.pm line 94, line 2.
Month '-1' out of range 0..11 at PIM2smsxml.pl line 30
Great job, thank you! I modified your scripts only slightly in order to get all the fields I need. It worked out just fine!
Nice tutorial, but i can't make PIM export SMS in that xml format (even after extracting the backup)
Hi! I'm having the same problem with migrating my info to the android. I can't seem to get your Perl files to open. It gives me a message, stating the null file has been deleted. I'm new to this so any help you can give will be greatly appreciated. thanks
sag mal ist es dann auch möglich mit dieser Methode den Schritt andersrum zu gehen ?
Thanks for the post mario but i can seem to get ure perl code for the sms backup to work.
What i did is open up ure code in wordpad and change the open(DATA),"
how do you run the code to convert the backup file of your text messages into a .xml file?
First of all thank you for the posts!
I normally used to take PIM Backup but I don't get your Perl way of converting it!
I have already exported the contacts by exporting as VCARD to CSV and to Google contacts but I am trying to Import SMS as well! By the way I am not in Programming :)
Plz help me out!
How can I use your script to convert the .pib file into xml? how can I start your script? thanks for the answer and best regards
Hi, I don't really get it who to run your perl script. I'm sorry, but I have no knowledge about such stuff. Could please eplain it. thx
Hi and thank you Mario for this very helpful article. Nevertheless I had some problems which I'd like to describe here:
First I have to say that once I got my old WM phone, I converted my SMS from my even older Nokia S60 device with a tool named "SMSImport". These SMS now hadn't set the correct field values when exported by PIM Backup. E.g. the recipient's phone number in a sent sms which sould be stored in field #20 instead was in field #2. Also these SMS did not actually have a type (sent or received) wherefore the perl script would not correctly assign them.
This only affected the old SMS not created by Windows Mobile. You needn't continue reading if you've never imported any SMS to your Windows Mobile phone from another device.
I modified the script that it would take care of the problems described above. You can find it here:
Now follow these steps:
1) Separately export sent and received SMS with PIM Backup so you have SMS of only one type in one file. You need to uncheck the "Binary backup" option in PIM to get plain text files.
2) PIM Backup created UTF-16 encoded files. I had to convert them to "UTF-8 without BOM" before Perl was able to read them correctly (on a Windows machine). But maybe I just misconfigured my Perl installation.
3) Use the modified perl script which lets you specify an additional argument to distinguish between sent and received sms. For the backup files with your sent SMS specify 0, and 1 for the others. Additionally this modified version uses data from field #2 if field #20 is empty. Run the script by typing: "perl PIM2smsxml_mod.pl "
4) Now import your generated sms.xml files successively with SMS Backup & Restore. That's it.
I have a backup file "backup.pib" containing all
I downloaded PIM2vCard now what do I do to import
my contacts with Android?? thanks
Hey all, thanks for all your work! I tried to use both the original Perl script and Koani's modified one to convert some text messages, and they both gave me the same error message:
"Use of uninitialized value $ARGV in concatenation (.) or string at PIM2smsxml
.pl line 4. readline() on closed filehandle DATA at PIM2smsxml.pl line 11."
I can't code so I have no idea what this means. The texts were exported from a phone running WinMo6.1 using the latest version of PIMbackup, and the PC I tried to run the script on was running XP SP2 and Strawberry Perl, if that's relevant.
After many errors :S i found some tips, so i share to you.
1) I do iconv contacts et sms with:
iconv -f utf-16 -t utf-8 CONTACTS
iconv -f utf-16 -t utf-8 SMS
2) substitute vim (sms)
*perl PIM2vcard.pl CONTACTS
*perl PIM2smsxml.pl SMS
I have a bug on one line, it's about smiley ;), so i del 2 ; and it's ok.
I forgot, you must create the vcf directory before launching the script for VCARD.
The tags have disappeared in the message. ""
1) I do iconv contacts et sms with:
iconv -f utf-16 -t utf-8 CONTACTS
iconv -f utf-16 -t utf-8 SMS
2) substitute vim (sms)
Okay, here is how it's done.
First, rename the file to .zip and unzip it, it should now give you a file called: msgs_YYYYMMDD.csm (where YYYY is year, MM is month, and DD is day).
Open this file in an editor (I used Notepad++ on Windows), change the Encoding to UTF8 without BOM and save the file.
Open the file in vim (on a linux box if you have one), run there commands:
Removes the ^M marker
Replace new lines with
Remove the incorrect new lines
Replace the with new lines again
Now save the file, and run it through the perl script:
Copy the sms.xml to your SD card and import the messages :-)
Sorry to butt in, but if the script isn't working for you and you don't know Perl (i.e. you're like me), you might want to try the Python conversion script I put together at http://piemaster.net/tools/winmo-android-sms-converter/ .
All you need is your PIM Backup file (.pib), and the script will do all the unzipping, converting and outputting for you. I've also got some instructions for what to do if you did a binary backup: you can import and re-export in plain text via a WinMo emulator.
Hope that helps! It's totally free, and just let me know if it doesn't work and I'll fix it up ASAP. Cheers!
I've managed to get a file which is converted by the perl script but i'm facing one problem: it's only able to recognize my sent sms the right way, the received sms are all not shown at the right contacts but all together in one contact. my sms.xml contains lines like this:
I think the sender address is not found correctly. The line in my source file looks like this:
0x00,0x00;"Steve Smith";"\"Steve Smith\" ";;"";"This is the msg text.";"";0;"\\Conversations";"SMS";"IPM.Conversation";;;1;;2011,07,19,15,35,00;2009,06,28,14,13,30;0;"";0;""
Can anyone help me? I don't understand the regex to get the address :-/
Backup iphone SMS messages and contact to computer(Mac) in:
Do you know of a way to export the appointments (calendar) from Windows Mobile Professional 6 to a CSV or to a format that will import into Android? I have the Galaxy Note II. I also have backed up the WMP6 with PIM Backup.
I want to transfer SMS from Windows 8 mobile to Android mobile. What set of instructions do I follow?
There is a simpler way to do this after you save backup with PIM backup (make sure you don't use compression while backing up). Just select vanilla text only options. Then, move your file to a PC. Rename the PIB file to rar (use WinRar). Or change to .zip and use use favorite option. Either way, it will extract a .csc file. You can open this file with Excel and see everything. After that, you can try the Perl program by Mario to convert to VCF. Or you can try importing direct into other contact programs.