Dovecot Linux

Restore trashed mails from dovecot maildir

To remove the “T”rashed flag from mails in a maildir, the files need to be renamed.

rename 's/(.+),ST$/$1,S/' ./**/*
rename 's/(.+),RST$/$1,RS/' ./**/*
rename 's/(.+),STab$/$1,Sab/' ./**/*
find . -type f -regex '.*,\(ST\|RST\|STa\|STb\|STab\)' -exec echo `echo {}` \;

I have also created a script which can be executed in the Maildir, searching for files and renaming the files: