Skip to Content

3 Ways to List all the files in an AWS S3 bucket

If you are a developer or sysadmin, you are likely to have worked with Amazon S3 at some point. S3 is a great storage option for static files, and it’s very easy to use. In this blog post, we will discuss three ways to list all the files in an S3 bucket.

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

List all the files in an S3 bucket with AWS CLI

The best way to list all the files in an S3 bucket is to use the AWS Command Line Interface (CLI). To do this, simply open a terminal window and type the following command:

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

The output of the command shows the date the objects were created, their file size and their path.

The parameters we’ve passed to the s3 ls command are:

Name Description
recursive performs the command on all files under the set prefix
human-readable displays the file sizes in human readable format
summarize displays the total number of objects and their total size

List all Files in a Folder of an S3 Bucket with AWS CLI

To list all files, located in a folder of an S3 bucket, use the s3 ls command, passing in the entire path to the folder and setting the --recursive parameter.

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

The output of the command only shows the files in the /YOUR_FOLDER directory.

List all the files in an S3 bucket with third-party tool

The third way to list all the files in an S3 bucket is to use a third-party tool such as Bucket Explorer. Bucket Explorer is a free and open source tool that you can download from the internet. Once you have downloaded and installed Bucket Explorer, simply open it and connect to your AWS account. Then, select the S3 bucket you want to list, and click on the “Files” tab. This will show you a list of all the files in that bucket.

We hope this blog post has been helpful in showing you how to list all the files in an S3 bucket. If you have any questions or comments, please feel free to leave them below. Thank you for reading!