title: how to mass change folder names in amazon s3 with a script
body: <p>I uploaded a bunch of images but accidentally named the folders with spaces. Now you can't access them cause obviously urls cant have spaces.</p>
  
  <p>I've downloaded the aws cli and was wondering how to change folder names? I've looked at the documentation but I'm still having trouble and hoping someone can help. </p>
  
  <p>I've tried the below command without any success:</p>
  
  <p><code>aws s3 mv "s3://mybucketname/firstfolder/second folder with spaces/" s3://mybucketname/firstfolder/secondfolderwithspaces/ --recursive</code></p>
  
  <p>How do I change the name of "second folder with spaces" to "secondfolderwithspaces"?</p>
  
  <p>Also, is there a way I can iterate through these folders? Something like </p>
  
  <pre><code>for folder in s3:/bucketname/firstfolder: 
       aws s3 mv "folder with spaces" folderwithspaces --recursive
  </code></pre>