Quoting Ed Blackman from 04 Aug (a Friday in 2023) at 1434 hours... > Any suggestions for a command line program to select emails for > deletion based on command line options? I specifically want one that > can remove emails that were received more than X days ago, but can > also express "but don't delete if they're flagged".
<snip> > I could call mutt (see, kinda OT!) with "-e" to tag, delete, sync, and > quit, but that seems fiddly and heavyweight. But if it's being run from cron overnight or something, are you ever going to notice? > I could give up on using the message headers to determine the message > date, learn how filenames are constructed in Maildir (to read the > flags) and use a shell script built around "find". I'm reasonably confident that all filenames (before the ':') are only convention (I convert an nntp spool to maildir and name them according to my own naming convention which everything (well, mutt and dovecot) then honours), and mtime is unused by anything and/or not to be trusted. So honetsly, I'd suggest mutt's -e, since it gives you mutt's pattern matching which is much more powerful than archivemail (admittedly, I only used that for trivial stuff and only many years ago) and likely more than anything else available. eg, instead of just "received more than X days ago and not flagged", mutt can let you select/ignore whole threads based on those parameters, and others alike. eg, I once had archiving setup on a folder-hook thus: folder-hook !(Maildir$|archive|search|mfolder|.r.) 'push "<sort-reverse>t<tag-pattern>~m 600- !~(~m -600) !~(~r <32d) !~(~N) !~(~F) !~D<enter><tag-prefix-cond><save-message>^.archive<enter><enter><end-cond><sort-mailbox>t<collapse-all>"' To decode that: sort reverse threaded, select all messages after the first 600, but not if it's part of a thread within the first 600, not if it's in a thread with messages received in the last 32 days, not if it's in a thread with messages marked 'New' or 'Flagged', and not if it's a message already marked delete. Then save to the archive mailbox and established my desired sorting and thread collapse visibility. Basically - I wanted a thread-preserving archiving mechanism, and mutt's thread-aware pattern matching gave it to me. (I didn't include sync in that setup, preferring at the time to let that occur with mailbox closing) In a delete scenario as you're seeking, I'd suggest a multi-step process which first archives threads you've contributed to - and only then deleting old ignorable threads. Sure It's fiddly - which is your argument against using mutt. ...But it's powerful - which is my argument for using mutt! Aside - I used folder-hook before because I didn't know of the "-e" option, and I stopped using it because I found I was often using mutt as a mailbox debug tool, and this was just getting in the way. I can see myself going down the rabbithole and reimplementing my old archiver now (where "now" is "sometime in the next few months, maybe" :) .../Nemo -- ----------------------------------------- ----------------------------- earth native