Last updated: Feb 26, 2024
Reading time·3 min
To count the number of objects in an S3 bucket:
Objects
tab, click the top row checkbox to select all files and
folders or select the folders you want to count the files forActions
button and select Calculate total size
Summary
section of the page will display the Total number of objects
The page also displays the total number of objects in each of the selected folders.
s3 ls
command to count the bucket's objects.To count the number of objects in an S3 bucket with the AWS CLI, use the
s3 ls
command, passing in the recursive
, human-readable
and summarize
parameters.
aws s3 ls s3://YOUR_BUCKET --recursive --human-readable --summarize
YOUR_BUCKET
placeholder with the name of your S3 Bucket, otherwise, you'd get an AccessDenied
exception.The bucket in the example contains a total of 5 objects.
We specified the following parameters in the call to the s3 ls
command:
Name | Description |
---|---|
recursive | applies the s3 ls command to all files under the specified directory |
human-readable | displays the file sizes in human-readable format |
summarize | displays the number of objects and total size of the files |
1,000
list requests is $0.005
in the us-east-1
region.To count the number of objects in a specific folder in your S3 bucket, use the
s3 ls
command and specify the path of the directory, e.g.
s3://my-bucket/images/
.
aws s3 ls s3://YOUR_BUCKET/folder/ --recursive --human-readable --summarize
The output shows that the personal-website-bac/
directory consists of 4
objects.
You can learn more about the related topics by checking out the following tutorials: