Skip to content

Instantly share code, notes, and snippets.

@antpaw
Created November 21, 2022 12:54
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 antpaw/102615cad9c2bd0d158d651c294709a0 to your computer and use it in GitHub Desktop.
Save antpaw/102615cad9c2bd0d158d651c294709a0 to your computer and use it in GitHub Desktop.
list s3 and iterate
#!/bin/bash
SOURCE_BUCKET="some-bucket-x"
PROFILE="my-profile"
content=$(aws s3api list-objects-v2 --profile=$PROFILE --bucket $SOURCE_BUCKET --query 'Contents[?(LastModified > `2021-09-01`)]' --prefix some/path | jq -r ".[].Key")
for file in $content;
do
XE=$(echo $file | sed -e "s/.png.png/.png/g")
aws s3 mv s3://$SOURCE_BUCKET/$file s3://$SOURCE_BUCKET/$XE --profile=$PROFILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment