且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从谷歌硬盘垃圾文件夹中自动删除文件?

更新时间:2022-10-20 19:04:16

正如在[永久删除文件从谷歌驱动器],您可以启用云端硬盘API,以通过Appscript访问该方法。查看 appscript配额,以确保您的实施可以支持呼叫该API每隔十分钟一次。



您可以使用此解决方案:

  function createTimeDrivenTriggers(){
ScriptApp.newTrigger('emptyThrash')
.timeBased()
.everyHours(1)
.create();


函数emptyThrash()
{
Drive.Files.emptyTrash();
}


There are several articles, but I am not able to put a code together to run it successfully.

here one article I have looked at: Permanently delete file from google drive

I would like to automatically delete google trash folder items every hour or so. Prefer every 10 minutes. Google need to implement this useful feature.

As stated on [ Permanently delete file from google drive ], you can enable the Drive API in order to get access to the method, through Appscript. Take a look at appscript quotas to ensure that your implementation can support calling the API every ten minutes.

You can use this solution:

function createTimeDrivenTriggers() {
  ScriptApp.newTrigger('emptyThrash')
      .timeBased()
      .everyHours(1)
      .create();
}

function emptyThrash()
{
  Drive.Files.emptyTrash();
}