By spencer, Thursday, October 2, 2008 · 9:05 am

Ran into a problem with Exchange. I created a server-side rule to place spam messages in a folder that didn’t exist. All spam was instead going to the root folder, the folder above my inbox. Well if you use Entourage to access Exchange you will not be able to access this folder. If you go into Outlook Web Access (OWA) you can navigate to the root user folder by clicking on “Folders”.

Unfortunately by this point I had like thousands and thousands of messages. There is no “Delete All” option in OWA. Craptacular. So moving on I mounted the server via WebDAV in finder (cmd+k). The URL to mount will look something like:
http://exchange.servername.com/exchange/username

If this folder is large navigating to it in Finder will be a horrific experience. Open Terminal.app and navigate to the mountpoint.

~/> cd /Volumes/username

Once again, if the folder is large rm *.EML will not work as the wildcard expansion done by bash will exceed the length of the command-line itself (32K by default IIRC). Try this:


/Volumes/username> SRC=./*.EML
/Volumes/username> for i in $SRC; do rm "$i"; done

This will cleanup most, if not all, of the mess. Some files will not be removed due to escape characters and escaped escaped characters etc. Open the folder in Finder and delete the rest. There are def. more elegant ways to handle this from a scripting standpoint but this was quick and worked.

Add your own comment or set a trackback

Currently 2 comments

  1. Comment by Ross

    Just shooting in the dark here, but wouldn’t something like this be faster than your for-loop rm:

    find . -maxdepth 1 -name \*.EML -print0 | xargs -0 -L 100 rm

    Which will do the deletions in batches of 100 instead of spawning a separate process for each deletion. (You can, of course, embiggen or shrink the -L parameter to find the maximal line length)

  2. Comment by spencer

    find . -maxdepth 1 -name \*.EML -print0 | xargs -0 -L 100 rm

    Good call Ross. I guess you could wrap that in a while loop and leave it set at 100 and let it crunch away until there are no more.

Add your own comment

Powered by WP Hashcash



Follow comments according to this article through a RSS 2.0 feed


Jump to start of page | Jump to posts