--- mb2md-3.20.pl.orig Sun Aug 22 14:35:59 2004 +++ mb2md-3.20.pl Sun Aug 22 14:38:32 2004 @@ -182,6 +182,9 @@ # following: # for i in *; do echo $i;su - $i -c "/bin/mb2md -s mail -l .mailboxlist -R -d Maildir";done # +# -i Output Maildir directory structure with IMAPdir style +# directory names for use with BincIMAP. +# # # Example # ======= @@ -396,7 +399,7 @@ } # get options my %opts; -getopts('d:f:chms:r:l:R', \%opts) || usage(); +getopts('d:f:chms:r:l:Ri', \%opts) || usage(); usage() if ( defined($opts{h}) || (!defined($opts{m}) && !defined($opts{s})) ); @@ -411,6 +414,7 @@ my $dest = undef; my $strip_ext = undef; my $use_cl = undef; # defines whether we use the Content-Length: header if present +my $imapdir = undef; # defines whether we output in IMAPdir format # if option "-c" is given, we use the Content-Length: header if present # dangerous! may be unreliable, as the whole CL stuff is a bad idea @@ -421,6 +425,14 @@ $use_cl = 0; } +# if option "-i" is given, we output Maildir hierarchy in IMAPdir naming +# format (e.g. Maildir/INBOX, Maildir/Mailbox1, etc.). Useful for BincIMAP +if (defined($opts{i})) { + $imapdir = 1; +} else { + $imapdir = 0; +} + # first, if the user has gone the -m option # we simply convert their mailfile if (defined($opts{m})) @@ -511,7 +523,7 @@ # Since we'll be making sub directories of the main # Maildir, we need to make sure that the main maildir # exists -&maildirmake($dest); +-d $dest or mkdir $dest,0700 or die("Fatal: Directory $dest doesn't exist and can't be created.\n"); # Now we do different things depending on whether we convert one mbox # file or a directory of mbox files @@ -523,6 +535,8 @@ } else { + # if IMAPdir output mode, append INBOX for inbox mbox + $dest .= "/INBOX" if defined($opts{m}) && $imapdir; print "Converting $mbfile to maildir: $dest\n"; # this is easy, we just run the convert function &convert($mbfile, $dest); @@ -645,6 +659,9 @@ # Converting '/' to '.' in $destinationdir $destinationdir =~s/\/+/\./g; + + # Make sure folders don't start with dot for IMAPdir style! + $destinationdir =~s/^\.// if $imapdir; # source dir my $srcdir="$mbroot/$oldpath/$dir";