[Windows Mobile Apps and Games] smotrs:
Editing the Msgs file

I've received several PM's regarding whether I was successful and how I manage to edit the Msgs file so that when it was restored it was correctly threaded on the phone. I'm gonna try to explain it here and will update it as I find I missed something or need to make it clearer.

First thing you need to do is successfully run the PIMBackup to create the PIMBackup(DATE).pib file. When you run the Backup routine, make sure you uncheck the binary backup option.

Copy the PIB file from your phone to your computer.

Open the PIB file with WinZIP or similar.

Extract the msgs(date).csm file to your computer.

With a text editor, do the following. I use Scintilla Text Editor, it's open source and very robust. But Wordpad.exe and even Notepad.exe will work in a pinch.

Open the msgs(date).csm file with a good text editor.

Visually scan the entire file to see that every line has a single text message entry. Some text's may come in with CRLF which will break the message up onto 2 lines within the file. You will have to rejoin that second line with the first line.

[a] Locate the second line and place the cursor immediately proceeding the first alpha/numeric character on that line.

Press backspace until it rejoins the first line and add a space if necessary to separate the words where the cursor resides.

[*]If you made any changes, save the file, don't exit or close the file.

With Excel or Calc (OOo equivalent to Excel), do the following. Note I'm using Excel so if your using Calc you'll have to locate the same items I describe from Excel.

[*]Launch Excel.

[*]Goto File>Open on the menu and navigate to and select the msgs(date).csm file.

[*]You should see a Text Import Wizard - Step 1 of 3 or similar window popup as this is not a valid Excel file and check the following options,

[a] Make sure you have the option Delimited chosen.

Start import at row 1.

[c] File origin set to Windows (ANSI).

[d] Click the Next button

[*]In the Step 2 of 3 window, check the following options,

[a] Add or Select the delimter ( ; ) semicolon.

Change Text Qualifier to {none}.

[c] Click the Finish button.

[*]Depending on the messages you have received, they should be within column F.

NOTE: If you type messages or receive messages with a semicolon, they will have carried over into the next column depending on how many semicolons were in the message. For those messages, you will need to copy the text from Column G and append it to Column F, deleting the now blank cell. To verify, all cells within Column G should have "" only.

Here's where we fix the threading of all the messages.

[*]Scroll over to Column P & Q (These are the dates of the messages).

[*]Select Column Q from Row 2 down to the bottom.

[*]Copy and Paste the selection in Column P at Row 2.

[a] Click cell Q2.

Press and hold CTRL+SHIFT then press the arrow down button.

[c] Press CTRL+C (Copy).

[d] Click cell P2.

[e] Press CTRL+V (Paste).

[*]Column P & Q should be identical with the exception of the header in Row 1. If not, try again before proceeding.

[*]Clear the current selection by clicking any other cell in the document.

[*]On the menu, click Data>Sort.

[a] Look for the option Header Row and select it.

Change the Sort By to Modify Time or Delivery Time.

[c] Click the OK button.

NOTE: At this point, all your messages should be resorted based on when they were originally delivered to your phone.

[*]Press CTRL+A (Select ALL) to select everything in the Excel document.

[*]Press CTRL+C (Copy) to copy the content to the clipboard.

[*]Locate the Text Editor window with the original document. If you closed it, you will need to reopen it.

[*]Press CTRL+A (Select ALL) to select everything in the original document.

[*]Press CTRL+V (Paste) to replace the content with the clipboard content copied from Excel.

Here's where a GOOD text editor comes in handy

[*]Locate any of the TAB characters in the document. If you look at the top of the document, you will see a TAB character between "Msg ID" and "Sender Name".

[*]Select the TAB character and press CTRL+C (Copy).

[*]Press CTRL+H (Find and Replace). The TAB character should automatically be entered into the Find what box. If not, press CTRL+V (Paste) to paste it into that box.

[*]Click the Replace with box and enter a semicolon ( ; ) character.

[*]Press the Replace All button.

Here's another critical step to make sure the file is not corrupt. By default, the first line (the headers) will have five trailing semicolons ( ;;;;; ). THESE HAVE TO BE REMOVED. Also, if you have ever sent messages to more then one person at a time, you will end up with extra semicolons at the end of that line where the message is located. To locate all these extra semicolons, do the following,

[*]Press CTRL+F (Find).

[*]Type 5 semicolons ( ;;;;; ) into the Find what box.

[*]Press the Find Next button.

[*]Delete ALL trailing semicolons on each line it stops at.

[*]Repeat the proceeding 2 steps until Find Next reports no more have been found.

[*]Close Excel (don't worry about saving) if it's still open.

[*]Save your newly modified msgs(date).csm file. DON'T ADD IT BACK INTO THE ORIGINAL PIB FILE. This way you have the original incase your editing of the msgs(date).csm file doesn't go as planned.

[*]Copy the newly modified msgs(date).csm file to your phone.

You should now have the original backup PIB file as well as the msgs CSM file on your phone. Do a restore of both files, one at a time using the PIMBackup software.

NOTE: When you do your restore of the PIB file, unselect the messages check box so that you don't restore the Un-Threaded original version. This will speed up the restore process of all your contacts, calendar, phone log, etc..