I'd like to use a trash folder in mutt. I know how to create a macro that moves mail to the trash folder instead of deleting. However, I'd also like to automatically delete messages that sit there for seven days (as Thunderbird can do).

My mail is stored in maildir format. I could create a crontab that deleted files/messages from the trash directory, but it'd have to know when files were transferred. I thought a simple way might be to touch files as they were transferred. Then, I could just delete based on modification date. Is there a way to do make mutt touch files as it moves them, or is there a better way to delete files periodically from the trash?

  • 2
    The ctime would reflect that time. gfind trash -ctime +7 -type f -delete. In maildir, the mtime is meant to reflect the date of the email. – Stéphane Chazelas Oct 5 '15 at 12:44
  • @StéphaneChazelas Oh brilliant. Thanks for that. Could you please make it an answer? I'll change the question to fit what I really wanted. (Also, out of interest, does a change in ctime mean mutt changed the file's inode too?) – Sparhawk Oct 5 '15 at 12:49
  • If it just does a rename(), the content of the inode should not change (other than the ctime). The content of the directories (and therefore their mtime) will be updated obviously. – Stéphane Chazelas Oct 5 '15 at 13:03

I'm unsure if this can be done within mutt itself, but this can be achieved by a script in your (ana)crontab instead.

find /path/to/trash-maildir/cur -ctime +7 -type f -delete

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.