title: S3: How do I search/find a file by name among multiple directories?
body: <p>I have a bucket on s3 containing a LOT of images (several 100 thousands). Each image has a very unique file name (a long hashed name) and are stored in a subdirectory named according to a corresponding object id in my database.</p>
  
  <p>A simplified example:</p>
  
  <pre><code>/bucket/1/red-1.jpg
  /bucket/1/red-2.jpg
  /bucket/1/red-3.jpg
  /bucket/2/blue-1.jpg
  /bucket/2/blue-2.jpg
  /bucket/2/blue-3.jpg
  </code></pre>
  
  <p>Now the problem is, that the id's in the database has been changed and by mistake the names of the subdirectories hasn't. This means that, according to my database, the image <code>red-1.jpg</code> should be in <code>/bucket/2</code> but it actually still resides in <code>/bucket/1</code>. So I need to be able to search among all subdirectories, find the file called <code>red-1.jpg</code>, and move that to the right directory (in this case <code>/bucket/2</code>). </p>
  
  <p>Note: The part about moving the files should be pretty straight forward, the biggest problem is by far how I can effectively search and find the path of those images, where I know the name, but not the current directory.</p>
  
  <p>I'm on ruby, but I'm pretty open to using whatever.</p>
  
  <p>PS. I saw something about amazons cloud search, but I don't know if that could be used for this..</p>