King0770-Notes-Nuking everything in a folder

King Notes nuking everything in a folder

This comes up once in a while in support; someone has thousands or millions of items in a folder, and they need to nuke the folder now.

Usually, the command to nuke everything in a folder is:

zmmailbox -z -m ef /MyStuff

However, if the folder actually has "millions" of items in it, you may be inclined to remove 100 items at a time, and let the script run until all the items are removed.



for msg in `zmmailbox -z -m search -l 100 "in:MyStuff" | grep conv | awk '{ print $2 }' | sed -e 's/^-//'`
echo "Removing "$msg""
zmmailbox -z -m dm $msg

You can also query against mysql in a for-loop, to remove 1000 messages at a time.


for i in `mysql mboxgroup71 -NBe "select id from mail_item where mailbox_id='3871' AND folder_id='2' LIMIT 1000;"`; do zmmailbox -z -m deleteMessage $i; done

You will need to know how the zimbra account is structured, see

Notable bugs:

Jump to: navigation, search