To rename a folder in an S3 bucket, you have to:
Objectstab, optionally use the search input to find your folder
Actionsbutton and select
Destinationinput field, enter the complete S3 URI pointing to the folder, e.g.
s3://YOUR_BUCKET/YOUR_FOLDER/and click on the
Move action creates a copy of the objects with an updated path and a new
last-modified date. The original objects contained in the folder are then
The action applies to all the objects in the specified folder.
To rename an S3 folder with the AWS CLI, run the
s3 mv command, passing in
the complete S3 URI of the current folder's location and the S3 URI of the
desired folder's location. To make the command apply to nested paths, set the
aws s3 mv s3://YOUR_BUCKET/YOUR_FOLDER/ s3://YOUR_BUCKET/NEW_FOLDER/ --recursive
We use the s3 mv command to move the contents of a directory recursively to a new directory, in other words to rename the directory.
The output from the command shows that the files stored in the bucket's
my-folder-1 directory were moved to the destination directory of
By setting the
--dryrun parameter we instruct the AWS CLI to print the
command's output without actually running it.
aws s3 mv s3://YOUR_BUCKET/YOUR_FOLDER/ s3://YOUR_BUCKET/NEW_FOLDER/ --recursive --dryrun
You can run the s3 ls command to verify the S3 Folder has been renamed.
aws s3 ls s3://YOUR_BUCKET/NEW_FOLDER/ --recursive --human-readable --summarize
You can also use the
s3 ls command to verify that the old folder does not
contain any objects:
aws s3 ls s3://YOUR_BUCKET/OLD_FOLDER/ --recursive --human-readable --summarize
The output from the
s3 ls command shows that the old folder contains 1 object
0 Bytes. That object is the s3 path - the "folder" itself.
If you want to delete the empty folder, run the
command. Let's first run it in test mode with the
--dryrun parameter because
it's a destructive operation.
aws s3 rm s3://YOUR_BUCKET/OLD_FOLDER/ --dryrun
If the output matches your expectations, run the
s3 rm command in real mode by
I've also written an article on how to rename a Bucket in AWS S3.
You can learn more about the related topics by checking out the following tutorials: