[hey, I've been busy]


Benjamin Scott <[EMAIL PROTECTED]> writes:

>   Does anyone here {have,know of} a utility that will take a Unix mbox
> format mailbox and split it into multiple mailboxes, based on the date of
> the messages.  I've done some looking (Google, CPAN), and was surprised to
> find nothing.

This is a goofy hack to split an arbitrary number of mboxes into a
bunch of files (sorted by *day*).

perl -MDate::Manip -e '
  undef $/; 
  $input = <>; 
  while ($input =~ /^(From (?:.|\n)*?)(?=\nFrom )/mg) {
    $mail=$1;
    ($headerDate) = $1 =~ /\nDate:\s+(.*)\n/;
    ($mungedDay = ParseDate($headerDate)) =~ s/\d\d:.*//; 
    push(@{$mdays{$mungedDay}}, $mail);
  } 
  END { 
    for $day (keys(%mdays)) { 
      open(DMBOX, ">mbox-$day") || die;
      for $mail (@{$mdays{$day}}) { 
        print DMBOX $mail;
      }
      close(DMBOX) || die;
    } 
  }' mbox0 mbox1 mbox2 ... mboxN

--kevin
-- 
"Quit it with the $#$%&(^ angry fruit salad email.  This is one of the
 stupidest email threads I have ever seen."

     -- commentary on a email thread I saw once, in which the majority
        of the participants were "Outlook-crazy" and insisted on using
        different *colors* as a quoting mechanism.


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to