2000-03-01-20:08:10 Conrad Sabatier:
> I'm going to have to look into this "maildir" format, I think. :-)
>
> By the way, is there a simple way to convert my existing folders
> to this format?
Within mutt, if you go
:set mbox_type="Maildir"
(or put that in your .muttrc), mutt will create new folders in
Maildir format by default. So if you open an MH folder, tag all the
messages with
T~A
then save them all to a new folder with
;snew-folder
(that's a semicolon, it is the "tag prefix") that will convert the
folder. However, since it's pretty darned interactive, it's not
appealing for batch conversion of lots of old folders. For that you
want something command-line.
I don't know what the files in MH format look like, but if their
contents look like RFC 822 messages (ideally without the leading
"From " line, although mutt doesn't care too much for most purposes)
you can just use "mv" to put them into foldername/new/. So if you
have a whole bunch of MH folders in ~/Mail/, then perhaps
cd ~/Mail
for d in *;do
mkdir $d/new
mv $d/* $d/new # ignore the error
mkdir $d/tmp $d/cur
done
The error to ignore will be something like
mv: cannot move `foo/new' to a subdirectory of itself, `foo/new/new'
If the files aren't exactly in RFC-822 message format, it might be
worth trying to fix them. And if the filenames are particularly
unlikely to be unique, it might be worth taking the trouble to
rename them. Perhaps
cd ~/Mail
for d in *;do (
cd $d
files=`ls`
mkdir tmp new cur
n=1
for f in $files;do
mv $f cur/`date +%s`.$$_$n.`hostname`:2,S
n=`expr $n + 1`
done
) done
(untested). That version puts them in folders marked as already
read, rather than into new. Files in cur/ should have suitable
flags.
As I said, if the files don't exactly contain RFC 822 messages, it's
worth making them so. E.g. if they start with mbox-style "From "
lines, you could delete the from lines with
perl -pi -e 'print unless 1..1' *
Or you could turn the "From " line into a header line, if e.g. you
wanted to save the delivery info (some MTAs put envelope sender in
the "From " line), with something like
perl -pi -e 's/^From /X-From: / if 1..1' *
(as I mentioned before, untested).
-Bennett
PGP signature