Remove empty milder folders
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
then I looked over list just to be sure it wasn’t mucked up and in the users root maildir:
# sh < list
and done.
I probably could do some research on how to combine those two awk pipes but this worked, and it was fast.
-- Apple broke AppleScripting signatures in Mail.app, so no random signatures.
On Mon, Jan 16, 2017 at 07:03:49AM -0700, @lbutlr wrote:
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
then I looked over list just to be sure it wasn’t mucked up and in the users root maildir:
# sh < list
and done.
I probably could do some research on how to combine those two awk pipes but this worked, and it was fast.
You may also want to *consider* removing those mailboxes from your subscriptions, too. I ran into this recently and IMAP considers the list of folders that exist and the list of folders that are subscribed to be separate entities. The RFCs specifically say that deleting a folder should not invalidate the subscription (presumably because you might want to remain subscribed to it if it comes back). If you don't unsubscribe, then some MUAs will show your folders as "greyed out".
So, depending on what you're trying to do, you might want to "doveadm mailbox unsubscribe -u "user@example.com" $MAILBOX".
-- Apple broke AppleScripting signatures in Mail.app, so no random signatures.
-- For more information, please reread.
On 2017-01-16 (08:48 MST), Darac Marjal mailinglist@darac.org.uk wrote:
On Mon, Jan 16, 2017 at 07:03:49AM -0700, @lbutlr wrote:
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
then I looked over list just to be sure it wasn’t mucked up and in the users root maildir:
# sh < list
and done.
I probably could do some research on how to combine those two awk pipes but this worked, and it was fast.
You may also want to *consider* removing those mailboxes from your subscriptions, too. I ran into this recently and IMAP considers the list of folders that exist and the list of folders that are subscribed to be separate entities.
Good point. I didn’t look at this for two reasons. 1) My mail client doesn’t;t support subscriptions 2) I was removing empty folders from a account that was acting as a backup for all the emails from a domain.
That said, it’s a good idea.
-- Apple broke AppleScripting signatures in Mail.app, so no random signatures.
participants (2)
-
@lbutlr
-
Darac Marjal