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

Re: delete mbox mail from command line



Mark Gillingham wrote:
> In Mutt, I just learned;), that one might delete messages more than 1 
> week old like this:
>
> D ~ >1w
>
> followed by q (quit) and y (yes, I want to purge the messages).
>
> How might I do this from the command line in Mutt or another application?

I don't know how to do that from mutt and the command line.  Although
I would be surprised if there was not a way.

If you use maildir style mailboxes then each message is saved in its
own file.  That means you can use normal commands to manipulate those
files.  Given a maildir format mailbox in ~/Mail/Maildir the following
commands work on them.  This looks at files older than 7 days of
modification time ago.

  find ~/Mail/Maildir -type f -mtime +7 -print0 | xargs -r0 ls -ld

Then to delete them the following.  WARNING: This deletes files!
Remove the echo to activate but only after you are sure.

  find ~/Mail/Maildir -type f -mtime +7 -print0 | xargs -r0 echo rm -f

You can look at just read messages leaving unread messages untouched
by finding only in the new directory.

  find ~/Mail/Maildir/new -type f -mtime +7 -print

Bob

Attachment: pgpn3ToI9MCBo.pgp
Description: PGP signature


Reply to: