So I can see S3 console and can get into my folder with files listing but I don't find way to find total number of files in it other than going thru pagination which does not work considering thousands of files.
-
3Does this answer your question? [How can I get the size of an Amazon S3 bucket?](https://serverfault.com/questions/84815/how-can-i-get-the-size-of-an-amazon-s3-bucket) – Synexis Jan 24 '21 at 23:51
4 Answers
This will list your objects, and in the end you'll see Total objects count, and size:
aws s3 ls s3://bucketName/path/ --recursive --summarize
just change bucketName with your bucket name and path is actually a folder within a bucket, if you need that as well (or remove it if you want the whole bucket)
you can also use s3api from cli:
aws s3api list-objects --bucket bucketName --query "[length(Contents[])]"
As noted in comment, can take a while in case of a large bucket.
- 301
- 2
- 5
This is easy to do in the new S3 console directly.
As shown here, select the S3 bucket, and then select the folder of interest. Next, click the Actions
button and select Get total size
as shown here:
Then you should get a popup showing you the number of objects in the folder and the calculated size like so:
- 198
- 1
- 6
-
-
If you have more than 300 files in a given path this is not a valid solution as it remains static above that – Ilhicas Jan 11 '22 at 17:04
Another way to grab just the number of objects in your bucket is to grep
for "Total Objects", which is part of the output automatically displayed when using --summarize
:
aws s3 ls s3://bucketName/path/ --recursive --summarize | grep "Total Objects:"
For a folder with 1633 files, this will return:
Total Objects: 1633
- 111
- 2