Dec 27, 2011 - Coderkitty, Ruby on Rails    No Comments

Ruby to the Rescue

A couple of days ago, I stumbled into the trouble of rounding up resumes and attachments.  There was a dump of all assets available from Amazon S3, and the files were organized according to folders and broken down by ids.  The task was simply to group them all into one folder.

Instead of wasting precious bandwidth, we had the initial file structure downloaded to an FTP site and was duplicated on a local machine.  Locally, manipulations were done to have all the files in one big folder.. via Ruby.

Amazon S3

Amazon S3

require 'fileutils'
x = Dir['**/*.*']
x.each do |url|
	FileUtils.mv(url, "/Users/username/Downloads/attachments/#{url.split('/').last}")
end

Steps:
1. You need to cd to the topmost directory where the attachments’ directories are found.
2. Prepare a directory where all the attachments would be put. This is the second parameter in line #4.
3. Execute the script found above.
4. ???
5. Profit!!!

Chris

Got anything to say? Go ahead and leave a comment!

  • Facebook
  • LinkedIn
  • FriendFeed
  • Twitter
  • Tumblr
  • Flickr
  • YouTube
  • Vimeo
Stop SOPA