#!/bin/bash set -e for maildir in Maildir Mail; do if ! [ -e ~/$maildir ]; then continue fi; ( cd ~/$maildir ; for listtype in lists bugs; do find . -maxdepth 1 -mindepth 1 -type d -iname "$listtype"'.*' -print0| xargs -0 -i bash -c 'A={}; (( $(find "$A" -type f -name "*" -not -name "dovecot*" -not -name ".imap*" -not -name ".customflags" | wc -l) == 0 )) && rm -rf "$A"'; done; find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -delete; ); exit 0; done;