Skip to content

Instantly share code, notes, and snippets.

@robinkraft
Created December 18, 2012 23:07
Show Gist options
  • Select an option

  • Save robinkraft/4332954 to your computer and use it in GitHub Desktop.

Select an option

Save robinkraft/4332954 to your computer and use it in GitHub Desktop.
Copy MODIS files for selected tile through selected date from one S3 bucket to another.
import boto
TILE = "h28v09"
MAX_DATE = "2006-02-18"
def main():
print "Connecting to S3"
# assuming AWS credentials are available as environment variables or in .boto file
conn = boto.connect_s3()
src_bucket_name = "modisfiles"
b_src = conn.create_bucket(src_bucket_name)
files = b_src.list("MOD13A1")
new_bucket_name = "formatest"
b = conn.create_bucket(new_bucket_name)
print "Copying files"
for i in files:
if TILE in i.name and i.name.split("/")[1] <= MAX_DATE:
print "Copying %s from %s to %s" % (i.name, src_bucket_name, new_bucket_name)
b.copy_key(i.name, src_bucket_name, i.name)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment