Get the Size of a Folder in AWS S3 Bucket

avatar

Borislav Hadzhiev

Thu Sep 23 20212 min read

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

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

shell
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 in the us-east-1 region. For example, if your folder contains 1,000,000 objects, the List operation would cost you 1,000 * $0.005 = $5

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

NameDescription
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

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee