lunes, 22 de octubre de 2012

To import Outlook PST files in Thunderbird:

sudo apt-get install readpst
readpst -r nameofyourPSTfilehere
 
 
 
 
t is in situations like this that I really appreciate my virtual Ubuntu!
I was preparing an old hard disk for reuse, I mean it was really old, 7 years old minimum. I found a PST-file on it from when I used Microsoft Outlook, and I got curious, what old emails would I find there?
Oh but behold, Thunderbird required Microsoft Outlook to import the PST-file, so what to do :-S? Ubuntu please rescue me! Ta-daaa, after some search I found a command utility called readpst, which can convert a PST-file to a folder hierarchy of plain text-files, one for each email in the PST-file, thank you Ubuntu (well actually Linux command utilities in general)!
First of all you might not have readpst installed, but that’s only an apt-get-call away, running the following command from the terminal:
> sudo apt-get install readpst
It doesn’t really matter if you already have the utility installed or not, you can use the command above to confirm whether the utility is installed and if it isn’t, well then you saved yourself a bit of time since it will be installed icon smile Importing a PST file to Thunderbird without using Outlook
My first few attempts with readpst didn’t turn out so well, but after some fine-tuning I came up with the following set of options for the readpst command:
> readpst -D -M -b -o pst thomas.pst
I will just briefly walk through the command options:
  • The -D option tells readpst to include deleted emails
  • The -M option tells readpst to include attachments in the mail-files and not as separate files in the file system
  • The -b option tells readpst to omit the RTF version of the email, which would otherwise be included as attachment in the mail-files
  • The -o pst option specifies where the output goes
  • And last but not least include your PST-file which needs to be converted
Voila! That was a huge step in the right direction, after running the command above I had a folder structure mirroring the original folder structure from the PST-file, well at least I assume that it’s pretty close to the same. However in the conversion all the email-files were given a number and nothing else, no extension, nothing!
I renamed one file from 1 to 1.eml and dragged it into a folder in Thunderbird installed on my native Windows 7, and the email was imported to Thunderbird, the email even got all of it’s attachments intact, super! I could just drag’n'drop import all my emails.
My next problem turned out to be, how on Earth do I add the eml-extension to all of these files? Should I do it manually? No no no, not in a million years, Ubuntu, rescue me again, please!
I needed to find a way to recursively scan through all the folders created by readpst and add the eml-file extension to the name, after a bit of Googling I found a shell script for recursion (sorry for my ignorance, not a master of shell scripting, not yet at least). I found the shell command for renaming, funny enough it’s called rename, and it allows you to use Perl regular expressions when searching for files to rename, sweet!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
rename_fun()
{
   # For each folder do
   for i in `ls -ltr | grep '^d'| awk '{print $8}'`
   do
      # Output the folder's name, to track progress
      echo $i;
 
      # Move down into the sub-folder
      cd $i;
 
      # Add the eml-extension to all files with numeric names
      rename 's/([0-9]+)$/$1.eml/' *
 
      # Recurse deeper down into the folder structure
      rename_fun
 
      # When done move up from the sub-folder
      cd ..
   done
}
 
# Call to rename files
rename_fun
WARNING: The script is not child-safe, start from the wrong working directory in the prompt and suddenly you have added the eml-extension for a whole lot of files, which were never supposed to be changed. Furthermore it assumes that no mail folders use spaces in the folder name, I only had to folders which contained a space in the name, so I opted for the lazy solution: I removed spaces from my mail folders.
The only setback about this setup, is that I had to manually drag’n'drop the converted emails into my Thunderbird, that did take me some time, but I ran out of good ideas to how I could get the eml-files into Thunderbird in a smarter way, if you know just how to do that, then please add a comment below, thank you in advance!
It goes with the story to tell, that these emails turned out to be from the period of 2000 – 2004 and they were not that interesting actually, so perhaps this was just a waste of time for me, but I thought it might help someone else. Feel free to comment on this post, good ideas and constructive critique are always welcome!
I have listed some references below, which helped me in the right direction, I thank everyone who has unwillingly or unknowingly contributed to set my curiosity at rest! Among the links below you will also find a Thunderbird plugin, but according to the comments it doesn’t work, and I didn’t try. I decided to pursue the readpst solution instead based on the Ruby project at Google Code, which by the way didn’t work for me either.
 

2 comentarios:

  1. Digital Tweaks offers a totally professional and influential PST to Thunderbird Converter to transfer whole set of Outlook items, including the messages, contacts, notes, calendar etc. Try it for free now! https://www.quora.com/What-is-the-simplest-way-to-convert-PST-to-Thunderbird-format

    ResponderEliminar
  2. I would like to share one more trustworthy utility for the same i.e. ZOOK PST to MBOX Converter. It offers the users to effortlessly migrate the emails in the batch mode along with all the data items included in it. It supports both Outlook PST format such as ANSI and UNICODE and also compatible with all the MBOX based email clients. It preserves all the email data and RTF formatting of the emails intact even after the conversion process.

    Check for more details:- PST to Thunderbird Converter

    ResponderEliminar