0

I go to https://script.google.com/ and want to use Google Apps Script and a trigger to automatically clean my Google Drive Trash once an hour.

I read on the forum that I need to enable the Google Drive API - I did it.

I'm only logged into one Google account.

I run the script function emptyThrash() { Drive.Files.emptyTrash(); }

and wait for the trash in my Google Drive to be emptied

But when I run the script to check, I get an error enter image description here

Why is the trash not clearing? Maybe Google has changed something and now I need to use a different code to empty the trash?

  • 1
    From your showing error message, it is considered that the reason for your current issue of `Drive is not defined` is due to that you have never enabled Drive API. So, please enable Drive API at Advanced Google services, and test it again. [Ref](https://developers.google.com/apps-script/guides/services/advanced#enable_advanced_services) – Tanaike Apr 15 '23 at 22:33
  • I thought that those threads might be answers to your question. https://stackoverflow.com/q/43838960 and https://stackoverflow.com/q/50823383 – Tanaike Apr 15 '23 at 22:54
  • 1
    Code is written improperly. Try `Drive.Files.emptyTrash()` – Cooper Apr 15 '23 at 23:36
  • My mistake was that I included the Google drive API here [link](https://console.cloud.google.com/apis/library) So the script gave an error You must add the Google drive API here - [link](https://script.google.com/) If someone had previously shared such a screenshot, I would have saved a lot of time ... ![Link](https://prnt.sc/xFfsoudmCNNy). – realmen80 Apr 17 '23 at 08:10
  • [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551/1772220) – ugexe Apr 17 '23 at 14:48

0 Answers0