sms-export.py for S60

What’s this?

I have a problem: I use a Mac and have a Nokia 6600 (S60) phone. I want to archive my short messages from the phone on my Mac. This far, I haven’t found any existing procedure or software for getting the short messages to my Mac. So I rolled my own small script using Python for S60.

Now this is the first time I’ve done anything in Python and the only guide I have had is the Python documentation on the Python site, so don’t expect wonders.

And a warning: you might have to edit the script to suit your needs!

The software

Version 0.2: sms-export-0.2.tar.gz. The second release. Click the link to download.
Version 0.1: sms-export-0.1.tar.gz. The initial release. Click the link to download.

What’s in the package?

The software consists of two Python scripts: sms-export.py, sms-export-to.py and sms-split.py.

sms-export.py is run on your phone. It produces one file, E:/sms-export.txt, from the contents of your inbox. The data is always appended to the file so you will want to rename or remove it after transferring it to your computer. Note that the script only fetches short messages and only from your inbox. The reason for this is that Python for S60 doesn’t provide more.

sms-export-to.py is also run on your phone and it appends to the same file as sms-export.py. It is used to export messages you have sent. This requires some manual work from you so see the instructions.

If you want to, you can split the file sms-export.txt into smaller files that will end up in the SMS subdirectory of this package. There will be one file per short message and each file will have a descriptive name. The modification date of the file is set to the date the message was sent. You do this by running the sms-split.py script.

As the split files have the sender in the file name and I couldn’t get Python to open files with other than ASCII characters in the name (for example Fåglar coded in Mac Roman), the non-ASCII characters in the file name are translated to ASCII abbreviations.

I use the file split feature to import short messages into Journler.

Quick instructions

First you need to install Python S60 on your phone. That is not all that trivial. You find the software and instructions on the Nokia Python for S60 site.

The difficult part is figuring out what package you actually should download and install. There are several releases of S60 and you need to get the Python that matches your phone. I found the Wiki useful for this purpose. You don’t need the SDK.

After you have installed Python on your phone, unpack the sms-export package somewhere. In this example, I’m using the desktop. Using Bluetooth, transfer the files sms-export.py and sms-export-to.py to your phone. The phone will get a new message. When you open the message, the Python installer starts automatically.

The installer will ask you how to install the python code. Select “install as Python script”.

Now start Python and select “run script”. You should find sms-export.py in the menu. Run it. When the script is done, it should print how many messages were exported.

Using some kind of file browser on your phone, navigate to the E: drive and send sms-export.txt to your computer. You are done.

If you want to export messages you have sent, not just received, do like this. Move or delete all current messages away from the inbox. Move all sent messages to the inbox. Run sms-export-to.txt. Move or delete the sent messages. Don’t leave them in the inbox. Transfer the file sms-export.txt to your computer.

If you want to split up the big file as one file per message, copy sms-export.txt to the sms-export script directory right beside sms-split.py. Now comes the tricky part. The file is encoded as UTF-8 and it needs to be Mac Roman if you want to continue.

I use SubEthaEdit for the conversion. Now it seems SubEthaEdit has gone commercial with a 30 day trial period. The older version I have is free for home use. There is likely to be some other good text file recoders out there for the Mac that you can use.

After converting the text file and saving it, start the terminal application and change into the sms-export directory. In this example you do like this:

cd Desktop/sms-export-0.1

Then you run the splitter like this:

./sms-split.py

You should get progress printouts as the file is being split. If you get file open errors you might have some non-ASCII characters in the sender name that the split script doesn’t take care of.

Add the missing character to the re.sub part for example like this:

who_file = re.sub("è", "e", who_file)

The usual disclaimer

This software comes with no guarantees of functionality. But it works for me.

Roadmap

Nothing on the roadmap at the moment…

13 Replies to “sms-export.py for S60”

  1. I really need this script. I inherited a phone with over 4500 texts on it, which I cannot delete. They make the phone so slow it is unusable. (Phone hangs for at least 10 minutes in order to send a text!)

    The links to the source files are broken. Can you please fix them?

    Thanks a lot, appreciate you sharing your work.

    Max

  2. Oops, I had accidentally removed the files when doing a major WordPress upgrade a while back, Now I have restored the files.

    There is a chance that Python will choke on the sheer amount of messages. I haven’t used the script myself for a while as I moved from the 6600 to a N95 but I remember that the 6600 didn’t like exporting a lot of messages at a time and crashed quite frequently. If you run into problems, it sometimes works if you just try again.

    By the way, what is it you want to do with the script? Delete the messages or export them? The script doesn’t delete the messages, it only exports them to a text file.

  3. Thanks for reposting.

    I wasn’t sure that you were going to respond, so I decided to write the script myself, as I was interested in writing a first-script for the phone anyway.

    I just wanted to note that you do not have to move your sent messages to the inbox in order to export them. Instead, when you initialize the inbox class in sms-export-to.py, you can give an inbox.ESent parameter, like this:
    inb = inbox.Inbox(inbox.ESent)
    this will access the sent folder instead of inbox.

    Anyway- I am trying to export the messages, not delete them. If I can get them off the phone, I get to keep the phone. As you predicted, python is running out of memory here:
    msgs = inb.sms_messages()
    with the error: “SymbianError: [Errno -4] kErrNoMemory”

    Before taking the Python route, I had found an application on the nokia site called “SMS Export”, which does the same thing. It also crashes when I try to run it on the 4500+ messages I have.

    This situation is pathetic. Do you have any ideas?

  4. The only thing I can think of is creating two new folders, say “tmp” and “store”. Move most of the messages to tmp. Then export whatever you have in the inbox, move the inbox messages to store, move 500 messages from tmp to the inbox, export, move inbox messages to store, and so on until you have exported all messages.

    Remember to rename the export file after every export run just in case.

  5. The problem must be the sms_messages method. If only instead of returning a list it returned an iterator…

  6. Hello guys… Following links to solution for my problem I saw this site… But I have not found anything I want…

    Max… There is some kind of solution for your problem. I am not sure if your phone support it, but we can try… It will not hurt… A lot :))

    1.First, make sure you have enough free space on your memory card for your messages.
    2.Turn off your phone, and turn it on (this will help to free all RAM)
    3.Go to Offline mode (Offline profile) – this will sure process will not be broken.
    4.Then, open Messages. Go to Options>Settings>Other>Store location>Memory card.

    This operation will take a long time, possibly 10 or even 20 minutes. After progress bar hide from your screen you will need to wait couple minutes more (like 3-4, in your case it can be more).

    Than connect your phone to PC and backup messages.

    Turn off the phone. Take out your memory card. Turn on the phone, and change store location to Phone memory. Turn off the phone again, put in memory card, and turn it back on. Now you will have empty Messages folders, but you will still have backup in your memory card and your PC.

    In case you want to perform backup again, just follow steps. New messages will be append to the older ones.

    I hope this will help you.

  7. NICE software…i really needed it.
    only a stupid question: is there a way to invert the order of sms’s in the exported file? (i mean older sms above, then the new one..)
    mat

  8. Thanx a lot! Your scripts have served me very well!

    I changed a few lines in the code:

    – the change suggested above for exporting the “Sent” folder without moving messages around

    – the original script gave me unix time stamps as dates, I converted to ISO8601 dates:

    from datetime import datetime
    # … other stuff

    # convert timestamp to “normal” date
    time = datetime.fromtimestamp(time)
    time = time.strftime(“%Y-%m-%d %H:%M:%S”)

    # … other stuff

    # no need for repr() now
    f.write(“Time: ” + time + “\n”)

    I’ve exported more than 500 each of incoming and outgoing messages. Thank you!

  9. @betabug: Nice to see the script is in use! I haven’t been using it myself in a while and don’t even have Python for S60 installed any more on my new phone.

    Still it would be nice to incorporate the fixes into a 0.3 release. You wouldn’t be interesting in making a new tarball, hosting it and posting the link here as a comment?

  10. Hi, I converted several time megabytes of SMS using this script, thank a lot.

    I made a french How-To here, including up-to-date method to install Python on S60 : http://linuxfr.org/users/siltaar/journaux/sauvegarder-les-sms-d-un-nokia-symbian

    I also released a small Python script to convert dates to ISO8601 here : https://github.com/Siltaar/lokala-s60-sms-export-humanize-datetime

    For sure, exporting Sent messages easier than moving messages around would be great.

    1. Thanks for the comment and improvement suggestion! Unfortunately I don’t have access to a Symbian phone anymore so I can’t improve the software.

Leave a Reply

Your email address will not be published. Required fields are marked *