Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google api 使用Apple脚本删除共享Google drive中的文件_Google Api_Google Drive Api - Fatal编程技术网

Google api 使用Apple脚本删除共享Google drive中的文件

Google api 使用Apple脚本删除共享Google drive中的文件,google-api,google-drive-api,Google Api,Google Drive Api,我有一个共享文件夹,其中一个编辑器通常会向其中添加文件。我想通过捕获文件夹的最后更改日期,用以下代码继续刷新文件夹。它的抛出错误,在我看来,由于我不是文件的所有者,我无法删除。有什么出路吗 function 7DayFlush() { // Log the files names and its last change info for the mentioned folder (by id) // Enter the ID between Bracket

我有一个共享文件夹,其中一个编辑器通常会向其中添加文件。我想通过捕获文件夹的最后更改日期,用以下代码继续刷新文件夹。它的抛出错误,在我看来,由于我不是文件的所有者,我无法删除。有什么出路吗

 function 7DayFlush()

    {

      // Log the files names and its last change info for the mentioned folder (by id)
      // Enter the ID between Bracket

      var mfolder = DriveApp.getFolderById('<i keep folder id here>');


      // Following will get files from the folder.  
      var lfiles = mfolder.getFiles();

      while (lfiles.hasNext()) {
        var file = lfiles.next();

        if (new Date() - file.getLastUpdated() > 7 * 24 * 60 * 60 * 1000) {

          //Following will delete the files which matches the above condition which is older than 7days in the specified folder.

          Logger.log(file.getName()+'----'+file.getLastUpdated());

//here is the error comes up.. help me.                    
          file.setTrashed(true);
//here is the error comes up.. help me.

        }
      }
    }
函数7daylush()
{
//记录所述文件夹的文件名及其上次更改信息(按id)
//在括号之间输入ID
var mfolder=DriveApp.getFolderById(“”);
//以下内容将从文件夹中获取文件。
var lfiles=mfolder.getFiles();
while(lfiles.hasNext()){
var file=lfiles.next();
如果(新日期()-file.getLastUpdate()>7*24*60*60*1000){
//以下操作将删除指定文件夹中与上述条件匹配且超过7天的文件。
Logger.log(file.getName()+'----'+file.getLastUpdated());
//这里有个错误出现了..帮帮我。
file.setTrashed(true);
//这里有个错误出现了..帮帮我。
}
}
}

是否让文件所有者对应用程序进行身份验证,以便您可以删除该文件?您不能删除您不拥有或无权删除的内容。@DaImTo首先感谢您的回复。现在我明白了,我不能删除我没有的文件,但是共享文件夹的所有者是我自己。通过浏览器,我可以删除文件夹上的文件,但我不能通过脚本执行相同的操作。希望我解释得很好,否则我会录制视频并发布。