3
votes

Is there a way to rename a Google Drive folder via the REST API?

The folders I want to do this with typically have subfolders and files inside them.

I've found documentation for renaming files, but nothing about folders.

2
Did you ever find a solution to this? Quite frustrating that you can rename files but not folders from what it appears.abass

2 Answers

2
votes

Use Drive API files.update. Your request body should look something like:

{
  "name": "newFileName"
}
1
votes

Folders are treated as files in the v3 API, therefore the endpoint you mentioned will work for folders, as well as for files.

If you want to do this via the REST API, you can do so by making a PATCH HTTP request to https://www.googleapis.com/drive/v3/files/[fileOrFolderId]

The request body should include:

{
   "name": "newFolderName"
}