Skip to Content

2 Ways to get folder size in AWS S3 bucket

AWS S3 storage is a cloud storage service offered by Amazon. It is a great way to store large amounts of data, and it is very reliable. It is also a great way to back up your data.

An S3 bucket is a container for storing objects (files and folders) in AWS S3. Buckets can be used to store data from different applications or to store data for backup and disaster recovery purposes. You can create as many buckets as you need, and you can choose the region where your buckets are stored.

How to create a AWS S3 bucket?

To create an S3 bucket, you need to log in to the AWS Console and go to the S33 service. Then, click on “Create Bucket”. Enter a name for your bucket and select the region where you want your bucket to be stored. After that, click on “Create”.

Now that you have created your bucket, you can upload objects to it. To upload an object, click on the “Upload” button and select the file that you want to upload. You can also drag and drop files into the bucket.

Get folder size in AWS S3 bucket with AWS console

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

  • Open the AWS S3 console and click on your bucket’s name
  • Optionally use the search input to filter by folder name
  • Click on the checkbox next to your folder’s name
  • Click on the Actions button and select 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.

understanding AWS S3 CLI

The AWS CLI is a powerful tool that lets you manage your AWS resource from the command line. In this section, we will discuss some of the most important commands for managing S3 buckets.

The aws s3 ls  command lets you list all the files in an S3 bucket. Here is an example of how to list all the files in a bucket:
aws s3 ls s3://MY_BUCKET –recursive –human-readable

aws s3 action location

  • AWS s3 stands for you are using the AWS and in that, you want to access the s3 (simple storage service) to perform the operation
  • Action stands for which operation you want to perform like cp(copy data), mv(move data), sync(sync data), ls(list data)
  1. aws s3 help – To get a list of all of the commands available in high-level commands.
  2. aws s3 ls – To get the list of all buckets.
  3. aws s3 ls s3://bucket-name – Will list all the objects and folders in that bucket.
  4. aws s3 ls s3://bucket-name/path/ – This command will filter the output to a specific prefix.


Get folder size in AWS S3 bucket with AWS Cli

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.

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

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


Name Description
recursive applies the s3 ls command to all files under the specified directory
human-readable displays the file sizes in a human-readable format
summarize displays the number of objects and total size of the files