<<< Date Index >>>     <<< Thread Index >>>

Re: Macro for archiving



* Richard J. Cattien <richard.cattien@xxxxxxx> [040519 19:07]:
> until now I'm archiving my mails manually via
> 
>   # cat foomailbox >> ARCHIVE/foomailbox
> 
> Well, since I'm subscribed to several high-traffic mailinglists, this
> gets annoying sometime. I wonder if there's a way to achieve this task
> with one single keystroke. How would a marco look which tags all mails
> in a certain mbox and moves(appends) them to a mbox with the same name, but in
> another directory?

I do exactly this, though my macro leaves 100 mails in the "current"
folder so that I can always see the most recent mails in the folder.

In .muttrc:

source "/home/jack/bin/folder-hooks.sh|"

In /home/jack/bin/folder-hooks.sh:

MAILDIR=/home/jack/Mail/
ARCHDIR=ArchiveM

cd $MAILDIR

for folder in * ; do \
        # Print out a folder hook line for each folder in the directory.
        [ -f $folder ] && printf "folder-hook =$folder 'macro index ,b \":set 
confirmcreate=no\\r<limit>!~N 
!~F<enter><sort-reverse>d<tag-pattern>~m>100<enter><sort-mailbox>t<tag-prefix><save-message>=$ARCHDIR/$folder<enter>,d<sync-mailbox>,D<limit>.<enter>:set
 confirmcreate=yes\\r:set mbox_type=mbox\\r\" \"Automatically archive all but 
last 100 messages\"'\n"
done


If you wanted to archive all mails, then you would replace
<sort-reverse>d<tag-patten>~m>100<enter><sort-mailbox>t in the above line by
<tag-pattern>.<enter>

Then pressing ",b" in the mailbox menu will archive those messages

cheers,
jack

Attachment: pgpEMbR6irGd8.pgp
Description: PGP signature