Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rename all files in a dovecot Maildir removing the "T" flag (T=Trash)
# (c) 2015 Mattanja Kern <>
# DOVECOT Maildir remove T="Trash" flag from all files in folders.
removeTrashFromFileName() {
rename 's/(.+),ST$/$1,S/' "$1"
rename 's/(.+),RST$/$1,RS/' "$1"
rename 's/(.+),STa$/$1,Sa/' "$1"
rename 's/(.+),STab$/$1,Sab/' "$1"
export -f removeTrashFromFileName
find ./ -type f -regex '.*,\(ST\|RST\|STa\|STb\|STab\)' -exec bash -c 'removeTrashFromFileName "{}"' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment