What is the best way to rename folders in AWS S3
Hi Experts,
The question is right in title.
I would like to know about an approach that could be best in terms of performance and preserving the empty folders for renaming folders. I've tried CLI but somehow it keeps the empty folders intact and doesn't move them over to the new directory.
Any help would be appreciated.
There is no direct way to rename a file or folder in S3. What you have to do is copy the existing file with a new name and delete the old one. For example:
aws s3 --recursive mv s3://<bucketname>/<folder_name_from> s3://<bucket>/<folder_name_to>
The same thing can be completed through the AWS Console, but you specifically called out performance, so CLI would be the way to go, especially if there's hundreds/thousands of files or folders.
What worked for me to rename an empty S3 folder was aws s3 mv s3://bucket-name/folder-name/ s3://bucket-name/folder-new-name/
Relevant questions
What is the best way to rename folders in AWS S3
asked a month agoRenaming Empty Folders in S3
asked a month agoCDK design Encapsulation and Dependencies
asked 5 months agoRedshift questions from AWS Customer
Accepted Answerasked 3 years agoS3 Batch Operations + Lambda to bulk rename objects
Accepted Answerasked 3 years agoSimple(?) question regarding Lambda, EC2 and user data
asked 2 years agoHow to access and/or mount Amazon public datasets to EC2
asked 4 months agoBest way to setup bucket with access points?
asked 5 months agoSimple(?) question regarding Lambda, EC2 and user data
asked 2 years agoTotal size of my buckets is not the same as what appears inside them
Accepted Answerasked 3 months ago
+1 to Joe's answer. We were answering at the same time :) didn't see until I hit submit