Remove empty milder folders

Joseph Tam jtam.home at gmail.com
Mon Jan 16 22:15:50 UTC 2017


@lbutlr <kremels at 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 at 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 at gmail.com>


More information about the dovecot mailing list