Created
November 21, 2022 12:54
-
-
Save antpaw/102615cad9c2bd0d158d651c294709a0 to your computer and use it in GitHub Desktop.
list s3 and iterate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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