Downloading all files from a Amazon S3 bucket

I was trying to download all files from an Amazon S3 bucket, and did not feel like clicking through all of the files. Here is the little Python(2) script I came up with:

import urllib2
print("Retrieving file list ...")
url = urllib2.urlopen('')
data =
print("Parsing file list ...")
import xml.etree.ElementTree
e = xml.etree.ElementTree.fromstring(data)
keys = e.findall('{}Contents/{}Key')
keys = filter(lambda k: ".zip" in k, [ k.text for k in  keys ])
print("Found files: " + str(len(keys)))
print("Start downloading ...")
import os
for k in keys:
        print("Downloading: " + k)
        with open("data/" + k, "wb") as f:
                f.write(urllib2.urlopen("" + k).read())
print("Done downloading.")

If anybody knows an easier way, please let me know.


VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Leave a Reply