Reputation: 171
I'm trying to rename my file toto.html by removing its extension using gsutils. My folder/files are organized this way:
toto ----|
|
|--file1.html
|
|--file2.txt
|
|-- ...
|
toto.html
So I used the command :
gsutil mv gs://my_bucket/toto.html gs://my_bucket/toto
the problem is by doing so, the file is moved inside the folder that has the same name as the directory. ( which is normal )
How can I rename my file without having this issue?
thanks in advance.
Upvotes: 0
Views: 1080
Reputation: 1494
Let me explain briefly about how directories work on Google Cloud Storage, as detailed in the documentation:
Cloud Storage operates with a flat namespace, which means that folders don't actually exist within Cloud Storage. If you create an object named
folder1/file.txt
in the bucket your-bucket, the path to the object isyour-bucket/folder1/file.txt
, but there is no folder namedfolder1
; instead, the stringfolder1
is part of the object's name.
So when you perform the move command gsutil mv gs://my_bucket/toto.html gs://my_bucket/toto
, gsutil interprets it like you would like to move the file inside the folder named toto
as there is no way to differentiate between the file and the folder.
What you could do to achieve the task is move the file inside a folder first to change its name and then get it back to root:
gsutil mv gs://my_bucket/toto.html gs://my_bucket/toto/toto
gsutil mv gs://my_bucket/toto/toto gs://my_bucket/
Upvotes: 2