Amazon S3通过AWS CLI将文件夹移动到其他路径 - 甚至仅包含子文件夹

发布于 2025-02-08 19:58:34 字数 398 浏览 0 评论 0原文

我在S3 AWS上的存储桶中有一些数据。我必须将其移至同一存储桶中的新文件夹。文件夹还包含子文件夹,有时还包含文件。我正在为此目的使用AWS CLI实用程序。不幸的是,它不会移动子文件夹和仅用于文件。我已经从浏览了IT文档不成功。

aws s3 mv "$S3_ROOT/src/" "$S3_ROOT/old/" --recursive

在上面的命令中,SRC包含应复制的子文件夹。就我而言,如前所述,有时子目录将是空的。

I have some data in a bucket on S3 aws. I have to move it to a new folder in same bucket. Folder contains sub-folders and some times files also. I am using aws CLI utility for this purpose. Unfortunately, It is not going to move a sub-folder and work for files only. I have browsed it documentation from this source, but not successful.

aws s3 mv "$S3_ROOT/src/" "$S3_ROOT/old/" --recursive

In above command, src contains a sub-folder that should be copied. In my case, as already said, sometimes sub-directory will be empty.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落叶缤纷 2025-02-15 19:58:35

在Amazon S3中,文件夹实际上并不存在。

例如,您可以将文件上传到Invoices/andar.txt,并且Invoices文件夹将“神奇地”出现。然后,如果对象被删除,则文件夹将神奇地消失(因为它永远不存在)。

一个例外是当用户单击S3管理控制台中的创建文件夹按钮时。单击按钮将创建一个与文件夹相同名称的零长度对象。这将迫使文件夹出现,因为该路径中有一个对象(即使该对象未显示)。

在您的情况下,似乎mv命令没有复制那些零长度的对象。

通常,最好忽略S3中的文件夹,而假装它们存在于您希望它们存在的地方,而不是“创建”一个空文件夹。

Folders do not actually exist in Amazon S3.

For example, you could upload a file to invoices/January.txt and the invoices folder will 'magically' appear. Then, if the object is deleted, the folder will magically disappear (because it never existed).

One exception to this is when a user clicks the Create folder button in the S3 Management Console. Clicking the button will create a zero-length object with the same name as the folder. This will force the folder to appear because there is an object in that path (even though that object is not shown).

In your case, it would appear that the mv command is not copying those zero-length objects.

In general, it is best to ignore folders in S3 and just pretend that they exist in the places that you want them to exist, rather than 'creating' an empty folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文