How to check the total number of object stored in S3 bucket in AWS?

I am searching my s3 bucket and I would like to know how can I check total number of objects (files) I have uploaded inside particular S3 Bucket on amazon web server? I am looking for easy solution here.

Asked by:- neena
: 8751 At:- 5/19/2020 2:40:41 PM
aws count files in s3 bucket amazon web service

2 Answers
profileImage Answered by:- bhanu

Here are some ways to get total number of objects stored in AWS S3.

Method 1:

  1. Go to your S3 Buckets, select the bucket
  2. In the next screen, check the folder, click "Actions" button, select total size
  3. You will see a pop-up, with Total Object count and total size.

Method 2:

Using S3 API

aws s3api list-objects --bucket BUCKETNAME --output json --query "[length(Contents[])]"

For a specific folder

aws s3api list-objects --bucket BUCKETNAME --prefix "folder/subfolder/" --output json --query "[length(Contents[])]"

Method 3:


aws s3 ls s3://bucketName/path/ --recursive --summarize | grep "Total Objects:"

Total Objects: 4023

Method 4:

Using S3 command

s3cmd ls -r s3://logs.mybucket/subfolder/ > listing.txt

You can use any of the above method, depending on your need.

At:- 5/20/2020 7:55:05 AM Updated at:- 10/1/2022 7:21:10 AM
Excellent answer, I find Method 1 very easy to check so used it, and it works, thanks 0
By : neena - at :- 5/29/2020 11:05:39 AM

profileImage Answered by:- pika

You can also use  --summarize switch which includes bucket summary information

Here is the example using amazon CLI

aws s3 ls s3://bucketName/path/ --recursive --summarize | grep "Total Objects:"

Total Objects: 7235


At:- 2/21/2022 8:55:52 AM

Login/Register to answer
Register directly by posting answer/details

Full Name *

Email *

By posting your answer you agree on privacy policy & terms of use

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly