Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename Folder in Google Drive via API

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.

like image 746
nhe Avatar asked Oct 21 '25 04:10

nhe


2 Answers

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

{
  "name": "newFileName"
}
like image 160
Adi Mabfalin Avatar answered Oct 26 '25 18:10

Adi Mabfalin


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"
}
like image 39
Crina Avatar answered Oct 26 '25 19:10

Crina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!