How To Rename Files And Folder In Amazon S3 ?
Last Updated :
16 Feb, 2024
S3 stands for Simple Storage Service and is a widely used object storage service provided by Amazon Web Services. S3 offers unlimited storage to its users and also enables them to store any type of data, whether it be text, images, videos, executable files, tar files, etc. The reason why S3 is popular is because of its scalable storage for data needs, security features, & high availability.
Step-by-step to rename files and folders in Amazon S3?
Note: There is no such method in S3 to directly rename the folder of files in Amazon S3. All we can do is copy the existing file with a new name and delete the old one.
Step 1: Log in to your AWS Management Console.
Step 2: Create an S3 bucket Here, we have created a bucket named "sumit1602"
Note: The S3 bucket name must be unique and in small letters

Step 4: Now create any folder in the bucket and upload the file into that folder


Step 5: Create one ec2 instance and login it here we have connected it using putty

Step 6: (Important): Make sure you gain root access using sudo -s and install aws cli (command line interface)
Step 7: (optional) After complete installation use aws s3 ls command to list out buckets present in s3

aws s3 ls
Step 8: After listing out used following command to move files from one folder to another folder, --recursive indicates that operation should be applied recursively to all the objects in s3
Note: Bucket name and folder name varies depending on folders and files you created

aws s3 -- recursive mv s3://bucket_name/folder_name s3://bucket_name/folder_name_to
Step 9: Now remove the old folder to remove use following type of command

aws s3 rm s3://bucket_name//old_folder_name --recursive
In this way you can indirectly rename the folder and files present in s3 bucket
How to rename the files or objects in Amazon S3
Note: Just like folders in s3 we cannot directly rename the files here we are moving the file into new destination and then remove the old file
Step 1: To Rename the file use following command
Note: Instead of cp we can use mv (move) command here

aws s3 cp s3://bucket_name/folder_name/file_name s3://bucket_name/new_folder_name/new_object_name
We can see that the successfully renaming to the new object name in below picture

Step 2: Then remove the old object

aws s3 rm s3://bucket_name/folder_name/old_object_name
Conclusion
In summary, renaming files and folders in an S3 bucket with the AWS Command Line Interface (CLI) is a powerful skill that can help with accurate and efficient data management in Amazon S3. As with any AWS operation, it is important to follow best practices, to ensure security, versioning, and access control considerations are all taken care of for a secure and seamless file and folder renaming process.
Similar Reads
How to Rename Files and Folders Using CMD? Renaming files and folders is a fundamental task for system organization. While it's simple through the graphical interface, using CMD provides more flexibility, particularly for batch operations or when the interface is unavailable.In this guide, youâll master the ren (or rename) command, a built-i
4 min read
How to Rename a Folder in Linux Renaming a folder in Linux is possible with Graphical User Interface (GUI) file managers as well as with powerful command-line utilities such as mv, rename, find, and rsync. Be it a novice utilizing Ubuntu, Debian, CentOS, Fedora, or Kali Linux or an expert dealing with bulk renaming in the terminal
12 min read
How To Read File From Amazon S3 Bucket Using Node.Js ? The AWS Simple Storage Service (S3) is a cloud service provided by Amazon Web Services (AWS) to store your data securely. There are different approaches to storing and retrieving data from AWS S3; one of them is by using aws-sdk provided by Amazon Web Services. In this article, we will provide you w
5 min read
Python - Move and overwrite files and folders In this article, we will be learning on moving a collection of files and folders where there may be files/folders with the same name as in the source name in the destination. So that we may need to overwrite the existing destination file with the source file. The shutil.move() method is used to move
3 min read
How to Rename Files in MacOS? Renaming files in MacOS is a simple yet essential task that can help you stay organized and improve your workflow. Whether you need to rename a single file or multiple files at once, MacOS offers several easy methods to get the job done. In this guide, we will provide step-by-step instructions on ho
4 min read