Image

Image

Search This Blog

Tuesday, September 02, 2014

A simple script to import .pst in thunderbird

#!/bin/bash
#
#(c)2014 sorinakis@g*il.com

if [ "$(whereis readpste | cut -d: -f2)" = "" ]; then.
 echo "Sending you to download readpst"
 kdialog --warningcontinuecancel "Go to http://www.five-ten-sg.com/libpst/ to download, then compile and install libpst
 Once libpst is installed please re-execute this script.
 If readpst is installed, but not in path, you have to comment the first section of $0" --continue-label "Go to site"
 if [ ! $? = 0 ]; then
  echo "Cancel Pressed. Exit"
  exit 2
 fi
 xdg-open http://www.five-ten-sg.com/libpst/
 exit 0
fi

# Prepare location
wrkfld=$TMP/outlook$$
export $(dbus-launch)
mkdir $wrkfld

# Convert pst
readpst -o $wrkfld -r "`kdialog --getopenfilename ~ '*.pst' 2>/dev/null`"

# Rename folder so thunderbird understands
find $wrkfld -type d | tac | grep -v '^$wrkfld$' | xargs -d '\n' -I{} mv {} {}.sbd
find $wrkfld.sbd -name mbox -type f | xargs -d '\n' -I{} echo '"{}" "{}"' | sed -e 's/\.sbd\/mbox"$/"/' | xargs -L 1 mv

#Cleanup empty folders
find $wrkfld.sbd -empty -type d | xargs -d '\n' rmdir

kdialog --msgbox "Conversion Done! Please create a subfolder in your Thunderbird's Local Folders,.
 then manuallly move $wrkfld.sdb into ~/.thunderbird/[profile]/Mail/Local Folders/[new folder]"

No comments:

Post a Comment

Blog Archive