1

Is there any way to rename Google Apps Script project using API? I can't find any appropriate method for this.

UPD: I want to change Project's name like

enter image description here

enter image description here

GhostKU
  • 1,898
  • 6
  • 23
  • 32
  • Do you want to rename the filename of the project of the standalone type or the container-bound script type? Or do you want to the rename the filenames of each script in the project? – Tanaike Apr 22 '18 at 22:16
  • It is container-bound GApps project it's parent is Google Sheet document. And I want to change project name not filename. –  GhostKU Apr 23 '18 at 12:06
  • Thank you for the additional information. By this, I could understand what you want. So I posted my answer. Please confirm it. – Tanaike Apr 23 '18 at 22:08
  • Did my answer work? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. – Tanaike May 01 '18 at 03:04

1 Answers1

2

You can modify the project name of the container-bound script type using Drive API. In order to use this, please retrieve the project ID, retrieve access token and enable Drive API.

End point :

PATCH https://www.googleapis.com/drive/v3/files/### project ID ###

Request body :

{
 "name": "### Modified name ###"
}

Note :

  • In Google Drive, the project name is the same to the filename of the project.
  • Unfortunately, in the current stage, the project ID cannot be retrieved from Spreadsheet. But by the recent update, the file ID of Spreadsheet got to be able to be retrieved from the project of the container-bound script type. I would like to expect that the project ID will be retrieved from Spreadsheet in the future.

Reference :

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Correct me if I'm wrong @Tanaike , but I think you can only access standalone projects this way. It is not possible to use neither [drive API](https://developers.google.com/drive/api) nor the new [apps-script API](https://developers.google.com/apps-script/api), in order to rename a bounded script (i.e. those scripts and macros created associated to a google spreadsheet or google document) – abu May 01 '19 at 17:11
  • @abu Thank you for your comment. About ``I think you can only access standalone projects this way``, now in my environment, I confirmed that the project name of the container-bound script type using Drive API v3 can be modified. About this situation, can I ask you the detail information about your situation of ``I think you can only access standalone projects this way``? – Tanaike May 02 '19 at 00:58
  • sorry for the delay: I have not even been able of searching for bounded scripts using drive (either web interface or api) by ther name or id. They simply don't show up in drive file listings. Maybe I am missing something: Could you please provide a link to a simple/empty bounded gsheet script, so I can see how to construct the url? I tried to do it this way, and it doesn't work https://drive.google.com/open?id= – abu Jun 10 '19 at 18:11
  • On the other hand, that kind of gdrive url works for opening non-bounded scripts by their id (or for other file types: images, pdfs, google sheets or docs, ... but not for my bounded scripts) – abu Jun 10 '19 at 18:21
  • I used Python to call Drive v3 API and get a directory listing. In that directory, I put a google sheet with a bounded appscript, and also a non-bounded appscript. Both the sheet and the non-bounded script show up in the listing. But the sheet-bounded-script does not appear. Perhaps google stores them in some other place which is accessible by Gdrive but it is not the same place where the google sheet is stored? @Tanaike if you know where it is, please tell us. But I have the feeling that these bounded scripts are simply NOT stored in gdrive, or hidden / not accessible from gdrive views – abu Jun 10 '19 at 19:03
  • @abu Thank you for replying. Unfortunately, I couldn't understand about your current situation from your replying. This is due to my poor English skill. I apologize for this situation. So can you post it as new question by including the detail information? Because also, I noticed that this thread was not your question. By posting it at new question, it will help users think of your solution. If you can cooperate to resolve your issue, I'm glad. – Tanaike Jun 10 '19 at 22:01
  • I have not questions @Tanaike I was just saying why I think that your answer is wrong. (you asked that to me in your previous comment, on may 2nd) – abu Jun 11 '19 at 07:38
  • @abu Thank you for replying. I apologize for my poor English skill. – Tanaike Jun 11 '19 at 07:38
  • Your English is good enough (better than mine). So, how do you access your bounded-script project from Google drive using its id? I think it is not possible @Tanaike (but I think it is necessary for your answer to work) – abu Jun 11 '19 at 07:41
  • @abu Thank you for replying. I apologize for my poor English skill. I cannot understand about ``how do you access your bounded-script project from Google drive using its id?``. If you want to retrieve the scripts from a project of the container-bound script type using API, how about using Drive API and Apps Script API? – Tanaike Jun 11 '19 at 07:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/194737/discussion-between-abu-and-tanaike). – abu Jun 11 '19 at 07:53