#!/bin/bash for listdir in lists bugs; do ( cd ~/Maildir; find $listdir -maxdepth 1 -mindepth 1 -type d | \ perl -ne 'chomp; $a = $_; $b = $a; $b =~ s/\./_/g; $b =~ s/\//./g; qx(ln -sf "$a" ".$b")'; ); ( cd ~/Maildir/$listdir; find . -maxdepth 1 -mindepth 1 -type d| \ xargs -n 1 -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; # Remove broken symlinks (cd ~/Maildir; find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -delete; );