skip to Main Content

I’m looking for advice on managing files and folders in Amazon S3. Specifically, is there a built-in function or best practice for renaming files and folders within S3?

I’m expecting to learn about any built-in functions or best practices for renaming files and folders in Amazon S3.

2

Answers


  1. With awscli or directly from AWS Console, to rename an object or multi-ones, you need to perform the move action.

    https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/mv.html

    • An object as an example
    aws s3 mv s3://${BUCKET}/${SOURCE_PATH}/myobj-oldname.json s3://${BUCKET}/${DESTINATION_PATH}/myobj-newname.json
    
    • A folder as an example
    aws s3 --recursive mv s3://${BUCKET}/${SOURCE_PATH}/ s3://${BUCKET}/${DESTINATION_PATH}/
    

    For specific application, you need to check if it supports AWSSDK and allows you to perform above actions or you may need to build a custom function by your own.

    Login or Signup to reply.
  2. It is not possible to rename objects in Amazon S3. Instead, they must be copied and then the original object must be deleted.

    The AWS CLI aws s3 mv command actually does the Copy and Move command for you.

    Folders do not actually exist in Amazon S3. Instead, each object has a Key (filename) that includes the full path of the object. Therefore, it is not possible to ‘rename a folder’ since the folder doesn’t exist!

    However, the AWS CLI can perform an equivalent function with aws s3 mv --recursive, which will move all objects in the indicated path.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search