[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Good mail management techniques?



> On (02/09/01 15:32), Andrew Pollock wrote:
> 
> > The main problem I have is that each mailbox/folder/whatever you
> > want to call it, grows without bounds. I wouldn't mind something to
> > automatically shoved mail in a folder for each month or something like
> > that, but I don't think that IMAP/Pine etc support multilevel folders,
> > or do they?
>

I don't sort into folders.  It's too time consuming to set up a new 
folder/rule for each topic and my mailer already
handles sorting by threads/sender/subject anyway - plus i can just grep
content if necessary.

I do archive read messages every week.  I have attached the perl and bash 
scripts I wrote to do that.  Either script works by itself, but the bash
script will choke if your maildirs are big.

Note that I am not a perl hacker so take the code with a grain of salt.
The scripts are made for Maildir style mailboxes.  If anyone has
anything for mbox I could use it  (I guess you could just archive
the whole mbox and start afresh, but that would archive unread messages
as well).

g

#!/usr/bin/perl -w
# small script to archive maildirs
# may be some tricks.  angus@3wsi.com 20010809

use strict;
use File::Copy;

my $maildir = "/home/ii/Maildir";
my $archive = "/home/ii/Maildir/old";

# make new maildir
my (undef, undef, undef, $mday, $mon, $year, undef, undef, undef) = localtime;
my $map = sprintf "%4d%02d%02d", $year+1900, $mon+1, $mday;

print "Making archive ".$map." ...\n";

my $box = $archive."/".$map;

(-d $box) or `maildirmake $box`;

# move message to new maildir change to mv after testing
foreach (glob $maildir."/cur/*") 
{
	#print $_."\n";
	move($_, $box."/cur/") or die "could not move $_\n" ;
}

# tarball archive
print "tarring archive ".$box." ...\n";
chdir $archive or die "Could not chdir to $archive\n";
`tar -cvzf $map.tar.gz $map`;

# remove maildir
print "removing maildir ...\n";
`rm -r $box`;


0;
#!/bin/bash
# small script to archive maildirs
# may be some tricks.  angus@3wsi.com 20010809
# bash version

MAILDIR="/home/ii/Maildir";
ARCHIVE="/home/ii/Maildir/old";

# make new maildir
DATE=`date +%Y%m%d`
echo making archive $DATE ...

BOX="$ARCHIVE/$DATE";
[ -d $BOX ] || maildirmake $BOX

# move message to new maildir # change to mv after testing ...

echo copying messages ...
mv $MAILDIR/cur/* $BOX/cur/

# tarball archive

echo tarring maildir ...
cd $ARCHIVE
tar -cvzf $DATE.tar.gz $DATE

# remove archive

echo removing maildir ...
rm -r $BOX


echo done

Attachment: pgpLkPiXETEFr.pgp
Description: PGP signature


Reply to: