Last active
October 6, 2023 06:52
-
-
Save cablespaghetti/0df897c23565fc5822c3f37f2d15e22e to your computer and use it in GitHub Desktop.
Find all files in S3 bucket with specific content-type
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
aws s3 ls s3://mybucket/ --recursive | awk '{print $4}' | parallel 'echo {}; if [ "$(aws s3api head-object --bucket mybucket --output json --key {} | jq .ContentType -r)" = "binary/octet-stream" ]; then echo {} >> dodgy.txt; fi' | |
cat dodgy.txt | grep png | parallel 'echo {}; aws s3 cp --content-type="image/png" --metadata-directive="REPLACE" s3://mybucket/{} s3://mybucket/{}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. I get following error when I run this script. (I replaced
mybucket
with my bucket name)How can I fix it ?