I am trying to rename a large amount of files located in an AWS S3 bucket. What I am doing is using psql
cli within my docker container image.
I did docker exec -it [dbname] bash
Then did psql -c -d [dbname] select * from t1
How can I access the results from the psql query above and also loop through it so that for each iteration, I will use AWS CLI command operations to move and rename object in bucket A to bucket B
E.g
//Results from query
**NAME**
George
Kim
Sam
**S3 Bucket A**
file_one.pdf
file_two.pdf
file_three.pdf
**S3 Bucket B (need to rename and move here)**
file_one_george.pdf
file_one_kim.pdf
file_one_same.pdf
I saw something like this aws s3 --recursive mv s3://<bucketname>/<folder_name_from> s3://<bucket>/<folder_name_to>
here stackoverflow
I need to run an AWS command similar to that post but need to loop through the psql query results. Not sure about this but do I also need some kind of logic for each file in the AWS Bucket A. Such as
if (file one name in bucket A == psql query result row[x] name)
//run aws cli command to rename file and move to new bucket