s3cmd « Intelligrape Groovy & Grails Blogs

Posts Tagged ‘ s3cmd ’

How to delete all contents/objects of Amazon S3 bucket

Posted by on November 12th, 2011

If you have an S3 bucket with a huge number of files, and you want to delete the bucket, you need to empty the bucket first. If the bucket has a handful of files, then it is easy enough from the AWS interface, but if the bucket has a large number of files, then AWS interface is not an option; and you must use s3cmd or may be some other tool which allows this.


s3cmd is a command-line tool for manipulating S3 buckets and objects; and as you would expect, it does have a way to recursively delete all objects in a bucket.

s3cmd del –recursive –force <bucket_url>


What’s annoying is that S3 does not provide this capability natively. The above command probably simply lists all the objects first internally; and then makes a delete call on each object.


It took me a while to figure this out, because it does not seem to be documented, I found this in one of the comments on S3cmd page.

-Deepak


Tags: ,
Posted in System