Get the Size of a Folder in AWS S3 Bucket

Borislav Hadzhiev

Last updated: Feb 26, 2024
2 min


# Get the Size of a Folder in S3

To get the size of a folder in an S3 bucket, you have to:

  1. Open the AWS S3 console and click on your bucket's name.
  2. Optionally use the search input to filter by folder name.
  3. Click on the checkbox next to your folder's name.
  4. Click on the Actions button and select Calculate total size.

calculate total size

Once you select the Calculate total size button you will be redirected to a screen where the total size of the folder is shown.

total size of folder

# Get the Size of a Folder in S3 using the AWS CLI

To get the size of a folder in an S3 bucket using AWS CLI, run the s3 ls command, pointing it to the folder's path and pass it the recursive, human-readable and summarize parameters.

aws s3 ls s3://YOUR_BUCKET/YOUR_FOLDER/ --recursive --human-readable --summarize

aws cli total size of folder

The command's output shows:

  • the date the objects were created.
  • individual file size of each object.
  • the path of each object.
  • the total number of objects in the S3 bucket.
  • the total size of the objects in the bucket.
S3 List operations cost about $0.005 per 1,000 requests, where each request returns a maximum of 1,000 objects (us-east-1 region).
For example, if your folder contains 1,000,000 objects, you would make 1,000 requests and the List operation would cost you $0.005.

We specified the following parameters in the call to the s3 ls command:

recursiveapplies the s3 ls command to all files under the specified directory.
human-readabledisplays the file sizes in a human-readable format.
summarizedisplays the number of objects and total size of the files.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.