I regularly need to sync a WordPress uploads directory from a S3 bucket towards a dev/local server.
On the S3 bucket, the uploads have a /version/ intermediate folder on top of the standard:
/wp-content/uploads/20**/**/file.* uploads folder architecture, so that it looks like
/uploads/20**/**/{version}/file.*
I know I can sync S3 to local with the AWS CLI following command: "aws s3 sync s3://your-bucket-name my-local-dir". But is there a way to sync the data while removing the {version}/ part during de process?
Thanks!
There's no way to do this via AWS CLI alone. You would need to develop a script to run after the s3 sync command finishes to move the files to a new directory and then deletes the old directories.