What is the PowerShell command for moving all files from folder A to folder B in an S3 bucket?
CodePudding user response:
You can use the AWS Command-Line Interface (CLI):
aws s3 mv --recursive s3://my-bucket/folderA/ s3://my-bucket/folderB/
It will perform a CopyObject
and a DeleteObject
object for each object in folderA
.
CodePudding user response:
This worked fo me
Get-S3Object -BucketName "mybucket" -Prefix "folderA/" | % { Copy-S3Object -BucketName "mybucket" -Key $_.Key -DestinationKey $($_.Key).Replace('folderA','folderB'); Remove-S3Object -BucketName "mybucket" -Key $_.Key -Force }