17 Jan
2017
17 Jan
'17
12:15 a.m.
@lbutlr kremels@kreme.com writes:
Not sure if anyone will find this useful, but this is how I deleted a bunch (several hundred) of empty mail folders from a user account:
# doveadm mailbox status -u ?user@example.com" messages "*" ALL | grep "=0" | awk -F= '{print $1}' | awk '{print "rm -rf ."$1}' > list ... I probably could do some research on how to combine those two awk pipes but this worked, and it was fast.
You can collapse all 3 downstream processes
doveadm ... | awk '/messages=0$/{print "rm -rf ./" substr($1,9}' >list
Needs shell escaping/sanitizing if you don't want to be the victim of mischief (e.g. maildir='X;cd ..;rm -rf *').
Joseph Tam jtam.home@gmail.com