I understand that in Amazon s3, there are only buckets and objects. There are no such things as folders and all files sit in the same bucket, and that objects that appear to be in a folder only have a prefix in front of their file name.
Now my question is... is there a way to change the PREFIX using AWS CLI?
PDFRSS. You can use prefixes to organize the data that you store in Amazon S3 buckets. A prefix is a string of characters at the beginning of the object key name. A prefix can be any length, subject to the maximum length of the object key name (1,024 bytes).
There is no direct method to rename the file in s3. what do you have to do is copy the existing file with new name (Just set the target key) and delete the old one.
You can use aws s3 mv command to rename or move files (objects) or folders (keys) in an S3 bucket.
All you have to do is to select a file or folder you want to rename and click on the “Rename” button on the toolbar. You can use the F2 keyboard standard hotkey tool. Now, type the new name and click ok. The file or folder will be renamed – as simple as that.
In awscli2 I was able to accomplish this with the following command:
aws s3 mv --recursive s3://bucket/prefix1/ s3://bucket/prefix2/
I ran a quick test (dryrun) prior to doing this by checking the output of:
aws s3 --dryrun mv --recursive s3://bucket/prefix1/ s3://bucket/prefix2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With