Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
maildir rotate? or How do I automate moving old messages?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
ggelln
Tux's lil' helper
Tux's lil' helper


Joined: 24 Jan 2003
Posts: 98
Location: Montreal Quebec

PostPosted: Wed Mar 31, 2004 3:50 am    Post subject: maildir rotate? or How do I automate moving old messages? Reply with quote

I use mutt.
I use maildir format.

I am not tremendously smrt at mail. (though I am willing to learn, and read, that is links are welcome!)

basically what I want is a method for sorting mail in my 'inbox' after
a certain amount of time? I have no idea how to go about this with
mutt/procmail etc (not even sure how to search for the answer!)

any ideas ?

Gabriel
Back to top
View user's profile Send private message
fcs
n00b
n00b


Joined: 01 Apr 2004
Posts: 14
Location: USA

PostPosted: Fri Apr 02, 2004 3:14 am    Post subject: Reply with quote

The nice thing about maildir format (well, one of many :) ) is that each message is an individual file, so you can use standard UNIX tools.

For example, to move everything older than 2 weeks in your Inbox to the "Old Mail" folder, do something like;

Code:
$ find $HOME/.maildir/{cur,new} -type f \! -name '.*' -mtime +14 -print0 | xargs -0ri mv \{\} "$HOME/.maildir/.Old Mail/cur"


This assumes, of course, that the "Old Mail" folder exits. I don't use mutt, but I assume it can create maildir folders. Of course, you can put the messages anywhere else too. Each file is a separate, unencoded mail message. Google for "maildir format" for details.
_________________
Insert witty comment here.
Back to top
View user's profile Send private message
ggelln
Tux's lil' helper
Tux's lil' helper


Joined: 24 Jan 2003
Posts: 98
Location: Montreal Quebec

PostPosted: Fri Apr 02, 2004 5:08 am    Post subject: Reply with quote

thanks, I like the solution!
I guess I didn't really need to use mutt :-)

Gabriel
Back to top
View user's profile Send private message
rfujimoto
Apprentice
Apprentice


Joined: 22 Mar 2004
Posts: 195

PostPosted: Fri Apr 02, 2004 5:18 am    Post subject: Reply with quote

To add to that, you could put a cron job in every 4 months to do this:

tar -cjf $(date +%w.%y).mail.tar.bz2 $HOME/.maildir/.Old Mail/cur

That way you can archive mail for as long as you like.
Back to top
View user's profile Send private message
nevynxxx
Veteran
Veteran


Joined: 12 Nov 2003
Posts: 1123
Location: Manchester - UK

PostPosted: Fri Apr 02, 2004 12:26 pm    Post subject: Reply with quote

rfujimoto wrote:
To add to that, you could put a cron job in every 4 months to do this:

tar -cjf $(date +%w.%y).mail.tar.bz2 $HOME/.maildir/.Old Mail/cur

That way you can archive mail for as long as you like.


Nice idea, why 4 months though? seems a bit arbitary. Is there a way with tar to add files to an existing archive? If so I'd have 2 cron jobs, one monthly that rotates the archives, and one nightly (say 4am?) that adds all mail into the "current" archive. The nightly one would also remove all mail over a month old. That should be fairly good.
_________________
My Public Key

Wanted: Instructor in the art of Bowyery
Back to top
View user's profile Send private message
ggelln
Tux's lil' helper
Tux's lil' helper


Joined: 24 Jan 2003
Posts: 98
Location: Montreal Quebec

PostPosted: Fri Apr 02, 2004 1:36 pm    Post subject: Reply with quote

man gentoo forums are great!
ask a random questions, get lots-o-fun answers . . . well off to make a cron job

Gabriel
Back to top
View user's profile Send private message
nevynxxx
Veteran
Veteran


Joined: 12 Nov 2003
Posts: 1123
Location: Manchester - UK

PostPosted: Fri Apr 02, 2004 1:47 pm    Post subject: Reply with quote

ggelln wrote:
man gentoo forums are great!
ask a random questions, get lots-o-fun answers . . . well off to make a cron job

Gabriel


careful though, sometimes those fun answers lead to hacking ebuilds, and its not far from there to hacking source, and once you start that you see progs that need to be made, and then you are really in trouble.
_________________
My Public Key

Wanted: Instructor in the art of Bowyery
Back to top
View user's profile Send private message
fcs
n00b
n00b


Joined: 01 Apr 2004
Posts: 14
Location: USA

PostPosted: Fri Apr 02, 2004 2:26 pm    Post subject: Reply with quote

nevynxxx wrote:
Is there a way with tar to add files to an existing archive?


Code:
 $ man tar
<snip>
FUNCTION LETTERS
       One of the following options must be used:
                                                                               
<snip>
 
       -r, --append
              append files to the end of an archive
                                                                               
<snip>
                                                                         
       -u, --update
              only append files that are newer than copy in archive

<snip>


So something like:
Code:

$ tar -ujf $HOME/mail.tar.bz2 $HOME/.maildir/{cur,new}

should do it.

Note: if you use an IMAP mailreader you probably have a bunch of other folders in your maildir, use ls -a to see them, as their names all start with a '.'. Each of these subfolders have tmp, new, and cur directories as well. If you have multiple levels of folders in your mail client '.' is used as the path seperator, so for example I have:
Code:
 $ ls -aFC ~/.maildir
<snip>
.Lists/
.Lists.Gentoo/
.Lists.OpenIB/
<snip>
cur/
new/
tmp/




nevynxxx wrote:
ggelln wrote:
man gentoo forums are great!
ask a random questions, get lots-o-fun answers . . . well off to make a cron job

Gabriel



careful though, sometimes those fun answers lead to hacking ebuilds, and its not far from there to hacking source, and once you start that you see progs that need to be made, and then you are really in trouble.


But that's the open-source way! :D
_________________
Insert witty comment here.
Back to top
View user's profile Send private message
nevynxxx
Veteran
Veteran


Joined: 12 Nov 2003
Posts: 1123
Location: Manchester - UK

PostPosted: Fri Apr 02, 2004 2:31 pm    Post subject: Reply with quote

fcs wrote:
<snip>
</snip>

cool thanks, I'll look at that later and run it into a script to pick up all my subdir's


fcs wrote:

But that's the open-source way! :D


Hehe your telling me! I meant it in a humourous way really, then again, I also just started ripping the gnome specific stuff from an app in order to make it cli.....
_________________
My Public Key

Wanted: Instructor in the art of Bowyery
Back to top
View user's profile Send private message
fcs
n00b
n00b


Joined: 01 Apr 2004
Posts: 14
Location: USA

PostPosted: Fri Apr 02, 2004 2:59 pm    Post subject: Reply with quote

nevynxxx wrote:
fcs wrote:
But that's the open-source way! :D


Hehe your telling me! I meant it in a humourous way really, then again, I also just started ripping the gnome specific stuff from an app in order to make it cli.....


So did I, thus the grin :D. Besides, I have a soft spot in my heart for anyone willing to rip out a GUI and replace it with something usable! ;)
_________________
Insert witty comment here.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum