Reputation: 103
I have some old uploaded S3 objects that were supposed to be in a subfolder/filename format, but mistakenly used a backslash which made the subfolder part of the actual object's filename.
Using the aws cli, how will I be able to recursively run through all my objects that have a backslash (folder\file
), make a new subfolder with the foldername, and place the object with the correct filename inside (folder/file
)?
From this
bucket
folder1\file1
folder1\file2
folder1\file3
To this
bucket
folder1
file1
file2
file3
Upvotes: 0
Views: 1134
Reputation: 57184
S3 does not have "folders", it only has "keys".
You need to list all the objects and then copy the object to a key with proper / in it, e.g. folder1/file1
, then you can delete the old file. There is no move operation in S3. And you will not need to create a folder. "Folders" only exist within the aws web console since they are needed for human interaction.
Upvotes: 2