Back
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?
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 S3Connectionconn = S3Connection('access-key','secret-access-key')bucket = conn.get_bucket('bucket')for key in bucket.list(): print key.name.encode('utf-8')
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
Learn how we helped 50,000+ professionals like you !
31k questions
32.8k answers
501 comments
693 users