Skip to content

Instantly share code, notes, and snippets.

@mattanja
Last active November 19, 2015 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattanja/1367bc04750dd105317f to your computer and use it in GitHub Desktop.
Save mattanja/1367bc04750dd105317f to your computer and use it in GitHub Desktop.
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