spc*_*971 3 cloud command-line-interface amazon-s3 amazon-web-services
我需要重命名 AWS S3 存储桶中存储的大量文件。每个文件/对象将单独重命名(基于特定标准 - 没有通用的“前缀/后缀”)。我提出了“current_filename”和“new_filename”列表,可以将其作为 .bat 文件/队列在 CLI 中执行。
是否可以通过 CLI 或以编程方式仅更新 AWS S3 存储桶中的对象键(键名称),而无需复制/移动文件,如下所示:
aws s3 cp s3://mybucket/folder/myfilename.jpg s3://mybucket/folder/my_NEW_filename.jpg
Run Code Online (Sandbox Code Playgroud)
我可以保持所有其他对象元数据相同,但文件名(键名)必须更改。
小智 5
您还可以使用 AWS S3 Move 命令将文件移动到新名称,而不是复制和删除文件。AWS S3 移动
# AWS Example
aws s3 mv s3://mybucket/test.txt s3://mybucket/test2.txt
# Copy file from local to S3
aws s3 cp robots.txt s3://ascisolutions.com
# Rename/move file
aws s3 mv s3://ascisolutions.com/robots.txt s3://ascisolutions.com/robots.txt.bak
# Move file to a directory in S3
aws s3 mv s3://ascisolutions.com/robots.txt.bak s3://ascisolutions.com/test/robots.txt.bak
# Rename/move file
aws s3 mv s3://ascisolutions.com/test/robots.txt.bak s3://ascisolutions.com/test/robots.txt
# Move file back to root directory of S3 bucket
aws s3 mv s3://ascisolutions.com/test/robots.txt s3://ascisolutions.com/robots.txt
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15383 次 |
| 最近记录: |