Create a gist now

Instantly share code, notes, and snippets.

Embed
Rename all files in a dovecot Maildir removing the "T" flag (T=Trash)
#!/bin/bash
#
# (c) 2015 Mattanja Kern <mattanjakern.de>
#
# 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