Bulk actions on emails from the command line

9 views
Skip to first unread message

Joost Kremers

unread,
Mar 2, 2016, 4:26:45 PM3/2/16
to mu-discuss
Hi all,

This isn't really a mu question, but I don't know a better place to ask,
and it's not entirely off-topic either, so...

I'm wondering if there's a good tool for performing bulk actions on
mails from the command line (or cron). I'm mainly interested in moving
mails to another folder (for archiving) and deleting mails (i.e.,
emptying the trash). At the very least, it should be possible to specify
which mails to move/delete based on the message date.

There's a utility called archive-mail that can do this, but it archives
mails in gzipped mboxes, which of course means that mu cannot index
them. I was wondering if anyone here knows of another utility or method
that could be used for this sort of thing.

TIA

--
Joost Kremers
Life has its moments

Ken Mankoff

unread,
Mar 2, 2016, 4:41:30 PM3/2/16
to mu-di...@googlegroups.com
Hi Joost,

I used to have a cron job that moved mail > 90 days old from the mu4e maildir Trash folder to the OS Trash, where it would eventually get really deleted.

mu find maildir:/trash AND date:100y..90d --sortfield=date --fields=l | xargs -J {} rm {}

-k.

Joost Kremers

unread,
Mar 3, 2016, 3:09:19 AM3/3/16
to mu-di...@googlegroups.com
Hi Ken,

On Wed, Mar 02 2016, Ken Mankoff wrote:
> I used to have a cron job that moved mail > 90 days old from the mu4e maildir Trash folder to the OS Trash, where it would eventually get really deleted.
>
> mu find maildir:/trash AND date:100y..90d --sortfield=date --fields=l | xargs -J {} rm {}

Of course! I completely forgot that I can use mu to find messages by
date...

(Can't find the -J argument to xargs, though. Where does that come from?)

Ken Mankoff

unread,
Mar 3, 2016, 7:25:44 AM3/3/16
to mu-di...@googlegroups.com

On 2016-03-03 at 03:09, Joost Kremers <joostk...@fastmail.fm> wrote:
> (Can't find the -J argument to xargs, though. Where does that come
> from?)

I'm on OS X so this is the BSD xargs.

-k.


> -J replstr
>
> If this option is specified, xargs will use the data read from
> standard input to replace the first occurrence of replstr instead of
> appending that data after all other arguments. This...
Reply all
Reply to author
Forward
0 new messages