Skip to content

Instantly share code, notes, and snippets.

@JadedEvan
Created March 29, 2010 22:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JadedEvan/348502 to your computer and use it in GitHub Desktop.
Save JadedEvan/348502 to your computer and use it in GitHub Desktop.
Copy files from one S3 bucket to another
#!usr/bin/env ruby
# This script takes a list of filenames from a given file and copies
# each of those files from one S3 bucket to another using the s3mcd library.
# Inputfile should have each filename termination by a newline character.
file, from, to = ARGV[0], ARGV[1], ARGV[2]
if file.nil? || from.nil? || to.nil?
puts "Invalid arguements. Should be filename from-s3-bucket to-s3-bucket"
exit
end
sizes = %w{106x 145x}
file = File.open(file, 'r')
file.each_line do |filename|
sizes.each do |size|
puts `s3cmd cp --acl-public s3://#{from}/Item/#{size}/#{filename.strip} s3://#{to}/Item/#{size}/#{filename.strip}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment