0 votes
1 view
in AWS by (19.2k points)

I have an amazon s3 bucket that has tens of thousands of filenames in it. What's the easiest way to get a text file that lists all the filenames in the bucket?

1 Answer

0 votes
by (44.6k points)
selected by
 
Best answer

You can use boto which is the AWS SDK for Python. You can do this in a few lines of code:

from boto.s3.connection import S3Connection

conn = S3Connection('access-key','secret-access-key')

bucket = conn.get_bucket('bucket')

for key in bucket.list():

    print key.name.encode('utf-8')

Save this like filename.py, and then run it like this:

$ python filename.py > results.txt

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...