Wednesday, March 16, 2011

Want to delete all items in your Amazon S3 bucket?

If you try to delete an S3 bucket while there are still items inside, you’ll get the error message

The bucket you tried to delete is not empty. Please delete all objects and folders in the bucket and try again.

Amazon S3: The bucket you tried to delete is not empty. Please delete all objects and folders in the bucket and try again.

If you have items are in the root folder of a bucket, you have to delete them first. Sounds easy, unless you have millions of object in your bucket! To make matters worse, there is no API to empty a bucket.

You have several options.

  1. Try to empty the bucket through the web interface: There is no Select All button, and if you try to select too many objects at once you’ll get a Loading… screen which loses your selection. And if your keys contain strings like // or \ the web interface will break.
  2. Use a client app: CloudBerry Explorer for Amazon S3 or SpaceBlock for Windows are good. Unfortunately, they are not multithreaded so deleting millions of objects can take a long time. Recommended.
  3. Write some code: written by Jonathan Kamens is extremely helpful. Maxim Veksler’s BucketDestroy Java app has got me out of trouble too. These scripts are your only option if you have keys with control characters in their names.

To avoid this problem in the future, create a folder within your bucket and place all your files there.


  1. Going to test Spaceblock! After hours of clicking "Delete" on folders....
    I'm migrating form JungleDisk/S3 to Crashplan, but deleting 80 GB is like clicking until the end of your live.

  2. Try this: bucket.delete_keys(bucket.list())

  3. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java EE Online Training from India. or learn thru Java EE Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

    Download latest cracks of mac & pc softwares. You can get full versions of latest games, softwares, applications and many tools. Macdrive Pro Crack Free Download