King0770-Notes-Nuking everything in a folder: Difference between revisions

(New page: 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.<br> Usually, the command to nuke everything in a fo...)
 
No edit summary
Line 13: Line 13:
#!/bin/bash
#!/bin/bash


while true
for msg in `zmmailbox -z -m user01@domain.com search -l 100 "in:MyStuff" | grep conv | awk '{ print $2 }' | sed -e 's/^-//'`
do
  do
for msg in `zmmailbox -z -m user01@domain.com search -l 100 "in:MyStuff" | grep conv | awk '{ print $2 }' | sed -e 's/^-//'`
echo "Removing "$msg""
do
zmmailbox -z -m user01@domain.com dm $msg
echo "Removing "$msg""
zmmailbox -z -m user01@domain.com dm $msg
done
done
done


</pre></code>
</pre></code>

Revision as of 17:36, 5 March 2010

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 user01@domain.com 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.

Example:


#!/bin/bash

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


Notable bugs:
http://bugzilla.zimbra.com/show_bug.cgi?id=38473

Jump to: navigation, search