Amazon S3 Console: How to find total number of files with in a folder? [duplicate]
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.
Solution 1:
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.
Solution 2:
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:
Solution 3:
if you just need the number of files without actually printing the files you can pipe what @Caldazer proposed to wc -l
like
aws s3 ls s3://bucketName/path/ | wc -l
Solution 4:
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