I am no Perl wizard, but this works:

lithium:~$ more /usr/local/bin/convertbox 
#!/usr/bin/perl

# usage:  convertbox [mbox] [dir for maildir to placed]
#
# ie:   convertbox /usr/mail/blah/mbox /var/qmail/mailhome/user/Maildir

require 'stat.pl';

($mbox, $maildir) = @ARGV;

chdir($maildir) || die("fatal: unable to chdir to $maildir.\n");
    
-d "tmp" || mkdir("tmp",0700) || die("fatal: unable to make tmp/ subdir\n");
-d "new" || mkdir("new",0700) || die("fatal: unable to make new/ subdir\n");
-d "cur" || mkdir("cur",0700) || die("fatal: unable to make cur/ subdir\n");

open(BOX, "<$mbox") || die ("fatal: unable to open $mbox");

while(<BOX>) 
        {
        if (/^From /) 
                {
                $fn = sprintf("new/%d.$$.mbox", $i);
                open(MDIR, ">$maildir/$fn") || die("fatal: unable to create new 
message");;
                chown ($uid,$gid,$fn);
                $i++;
                };

        s/^>From /From /;
        print MDIR || die("fatal: unable to write to new message");
        };

close(SPOOL);
close(BOX);


You'll need to do some chownage..






On Thu, 8 Jun 2000, Enrique Vadillo wrote:

> I'm switching more than 15.000 users to Qmail using maildirs,
> i'd like to know what is the best tool i can use in order to
> convert /var/mail/user mboxes into ~user/Maildir format and to
> convert ~user/Mail/folder into ~user/Maildir/.folder format too.
> 
> thanks!
> 
> Enrique-
> 

Reply via email to