使用Apple脚本删除共享Google云端硬盘中的文件

时间:2016-03-30 10:49:57

标签: 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

      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.

        }
      }
    }

0 个答案:

没有答案