[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Netscape 4.x Mailbox Conversion
From:       Andreas Pour <pour () mieterra ! com>
Date:       2002-07-02 6:42:03
[Download RAW message or body]

Hi,

I am not subscribed so please cc: me with any followups.

At the request of a client, who was converting a number of systems to
use KMail, I recently wrote a script to convert Netscape 4.x mail
directory structure into something KMail can understand.  I am attaching
the script.  Though it's a bash script, there's not much processing to
do and the efficiency could only be improved negligibly with a less
portable language.

It could possibly also use instructions to have KMail use the mbox
format.

If anyone sees any possible problems, please let me know, it did the job
fine in the few cases I tried it on.

One thing I noticed, though, that in case of very large mail archives (>
300MB), it takes (understandably) quite some time for KMail to generate
the indices.  The problem is that during this time there is absolutely
no KMail visual feedback, so perhaps when starting up for the first time
a splash screen could be put up or something.  Just a thought.

BTW, I am amazed at the speed with which KMail handles very large email
archives.  Great job!

Ciao,

Dre
["convertNetscape4xtoKMail.sh" (application/x-sh)]

#!/bin/bash

echo "It is possible that this script will delete valuable data."
echo "It is therefore *strongly* recommended that you make a backup of"
echo "your Netscape 4.x mail directory and run this script on the backup."
echo 
echo -n "Have you made a backup (y/n)?  "
read ans
if test "$ans" != "y" -a "$ans" != "Y" ; then
  echo "Very well, please make a backup and run this script again"
  exit 0
fi

echo
echo "You must be in the top-level of the Netscape 4.x mail directory"
echo -n "structure.  Are you in the top level (y/n)  ?"
read ans
if test "$ans" != "y" -a "$ans" != "Y" ; then
  echo "Very well, please go to the top level of the Netscape 4.x mail"
  echo "directory and run this script again."
  exit 0
fi

echo
echo "Starting conversion"

if test -e Inbox && ! test -e inbox ; then
  ln -s Inbox inbox
fi
if test -e Sent && ! test -e sent ; then
  ln -s Sent sent
fi
if test -e Trash && ! test -e trash ; then
  ln -s Trash trash
fi

rm -f .*.summary
more=t
while test "$more" = "t" ; do
  more=f
  for dir in *.sbd .*.sbd */*.sbd .*/*.sbd */*/*.sbd .*/*/*.sbd */*/*/*.sbd \
             .*/*/*/*.sbd */*/*/*/*.sbd .*/*/*/*/*.sbd ; do
    if test -d "$dir" ; then
      more=t

      # kmail uses the .directory instead of the the .sbd extension for sub-
      # folders, and also makes these dirs hidden
      new="$(echo "$dir" | sed -e 's@\.sbd$@.directory@')"
      if test "$(dirname "$new")" = "." ; then
        new=".$new"
      else
        new="$(dirname "$new")/.$(basename "$new")"
      fi
      echo "Processing $dir => $new"
      if test -e "$new" && ! test -d "$new" ; then
        echo "Error:  file '$new' exists but is not a directory, aborting"
        exit 1
      fi
      if ! test -d "$new" ; then
        mkdir -p "$new"
      fi

      # clean out any indices from the .sbd dir
      rm -f "$dir"/.*.summary
      # now move all folders from the .sbd dir to the new KMail .directory and
      # delete the .sbd dir
      mv "$dir"/* "$new"
      for sub in "$dir"/.* ; do
        if test "$(basename "$sub")" != "." -a \
                "$(basename "$sub")" != ".." ; then
          mv -f "$sub" "$new"
        fi
      done
      rm -rf "$dir"
    fi
  done
done

cat <<_EOF_
Finished the conversion.

If you have run KMail before, you will need to set the mail directory to
this directory and tell it to rebuild all the indices.

To do that, please edit your KMail configuration file:

  ${KDEHOME:-$HOME/.kde}/share/config/kmailrc

and change the line which begins with 'first-start=' in the '[General]' section
to the following:

first-start=true

and change the line which begins with 'folders=' in the '[General]' section
to the following:

folders=$(pwd)

Enjoy!
_EOF_

_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic