Skip to content

Instantly share code, notes, and snippets.

@eexit
Created September 19, 2017 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eexit/36bd70b660d0cf24dfe79bd114851f6f to your computer and use it in GitHub Desktop.
Save eexit/36bd70b660d0cf24dfe79bd114851f6f to your computer and use it in GitHub Desktop.
AWS S3 List + Rename Specific Files
#!/bin/bash
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
# Very importe: KEEP the --dryrun flag!!
aws s3 cp s3://bucket-name . --dryrun --recursive --exclude '*' --include '*.gzip' \
| tr "\r" "\n" \
| grep -v '^Completed ' \
| cut -d' ' -f3 > filename
#!/bin/bash
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
while read l; do
dest=$(echo $l | sed 's/.gzip/.gz/')
# Remove the --dryrun flag whenever you feel confident with the dryrun output
aws s3 mv $l $dest --dryrun
done < filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment