This page describes how to rename or move folders in a bucket with hierarchical namespace enabled.
Before you begin
Ensure that your bucket has hierarchical namespace enabled. For detailed instructions about enabling hierarchical namespace on a bucket, see Create buckets with hierarchical namespace enabled .
Required roles
In order to get the required permissions for renaming or moving folders in
buckets, ask your administrator to grant you the Storage Object User
( roles/storage.objectUser
) IAM role on the bucket.
For more information about granting roles on projects, see Manage access to projects .
To see the exact permissions that are required, expand the Required permissionssection:
Required permissions
-
storage.folders.rename - This permission is needed on the source folder.
-
storage.folders.create - This permission is needed on the destination folder.
You can also get the preceding permissions with other custom roles or predefined roles . For a more permissive role that lets you manage folders in addition to renaming folders, ask your administrator to grant you one of the following roles:
- Storage Folder Admin (
roles/storage.folderAdmin) - Storage Object Admin (
roles/storage.objectAdmin) - Storage Admin (
roles/storage.admin)
To see which roles are associated with which permissions, see IAM roles for Cloud Storage .
Rename or move a folder
During a folder rename operation, you can read and list the folders being renamed, but you can't run write operations on them.
Console
- In the Google Cloud console, go to the Cloud Storage Buckets
page.
-
In the bucket list, click the name of the bucket that contains the folder you want to move or rename.
-
In the Bucket detailspage, find the folder you want to move or rename.
-
If you want to rename the folder, do the following:
-
Click the folder's More actionsmenu.
-
Click Rename folder.
-
In the overlay window that appears, enter a new name for the folder.
-
Click Rename.
-
-
If you want to move the folder into a different folder, do the following:
-
Click the folder's More actionsmenu.
-
Click Move folder.
-
In the overlay window that appears, click Browse.
-
Select the destination folder for the folder you are moving. You can also click to create a new folder before you select it as the destination folder.
-
Click Select.
-
Click Move.
-
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting .
Command line
To rename or move folders within a bucket with hierarchical namespace, run the gcloud storage mv
command:
gcloud storage mv gs:// BUCKET_NAME / FOLDER1 gs:// BUCKET_NAME / FOLDER2
Where:
-
BUCKET_NAMEis the name of the bucket that contains the folder you want to rename or move. For example,my-bucket. -
FOLDER1is the name of the original folder that you want to rename or move. For example,my-src-folder. -
FOLDER2is the new name of the destination folder. For example,my-dest-folder. If the new name you choose is already being used by an existing folder, the original folder is moved inside the existing folder, becoming a child folder. For example, if you renamemy-dest-foldertomy-dest-folder1(andmy-dest-folder1already exists), the result ismy-dest-folder1/my-dest-folder/. If the new name you choose doesn't already exist, the original folder is renamed to match the new name.
The response looks like the following example:
Copying gs://my-bucket/my-src-folder to gs://my-bucket/my-dest-folder...
Client libraries
C++
For more information, see the Cloud Storage C++ API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
C#
For more information, see the Cloud Storage C# API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Go
For more information, see the Cloud Storage Go API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Java
For more information, see the Cloud Storage Java API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Node.js
For more information, see the Cloud Storage Node.js API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
PHP
For more information, see the Cloud Storage PHP API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Python
For more information, see the Cloud Storage Python API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .
Ruby
For more information, see the Cloud Storage Ruby API reference documentation .
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries .

