title: Is there a way to download objects from Amazon S3 based on certain tags?
body: <p>I am trying to download objects (files) from <code>Amazon-S3</code> but the problem that I am facing is keeping track of which objects have been downloaded as I have plenty of objects in each bucket and they increase with each day.</p>
  
  <p>I have been looking for a way so that I can <code>set/unset</code> some tag associated with each object. So when I have to download I can look for all the objects which have that particular tag not set, download them and then set their tag so they are downloaded again next time. Is there a way to do so? A sample example to do so will be helpful.</p>
  
  <p>I am using <code>boto</code> to download the objects through python. The current code that I have basically downloads single object that I have to name.</p>
  
  <pre><code>from boto.s3.connection import S3Connection
  
  conn = S3Connection( S3 Credentials )
  bucket = conn.get_bucket (Bucket Name)
  key = bucket.get_key(Object Name)
  key.get_contents_to_filename(Local Object Path to Download)
  </code></pre>
  
  <p><strong>UPDATED CODE:</strong>
  I am trying to copy the file from one directory to another directory within the same bucket using <code>boto's</code> <code>copy()</code> function. Here is my current code:</p>
  
  <pre><code>    conn = S3Connection( S3 Credentials )
      bucket = conn.get_bucket (Bucket Name)
      key = bucket.get_key(Object Name)
      key2= bucket.get_key(/new/dir/in_same_bucket/)
      key.get_contents_to_filename(Local Object Path to Download)
      key.copy(bucket.name, key2.name,metadata=None, preserve_acl=True)
  </code></pre>
  
  <p>When I do this I get error as <code>AttributeError: 'NoneType' object has no attribute 'name'</code>. How can I copy the file from one directory to another directory within same bucket using <code>copy()</code>?</p>