无法自动永久删除Google云端硬盘上的文件

福赞

我尝试使用Google脚本删除文件而不会造成垃圾,但是出现以下错误:

Drive.Files.remove(File.getId())

这是完整的脚本:

function DeleteOldFiles() { 

var Folders = new Array( 'FOLDER_ID_HERE', 'FOLDER_ID_HERE' ); 
var Files; 
Logger.clear(); 
for each (var FolderID in Folders) { 
Folder = DriveApp.getFolderById(FolderID);
 Files = Folder.getFiles(); 
while (Files.hasNext()) { 
var File = Files.next(); 
if (new Date() - File.getLastUpdated() > 7 * 24 * 60 * 60 * 1000) { 


 File.setTrashed(true); // Places the file int the Trash folder 
      //Drive.Files.remove(File.getId()); // Permanently deletes the file 
   Logger.log('File ' + File.getName() + ' was deleted.'); 
    } 
} 
} 
    if(Logger.getLog() != '') 
    MailApp.sendEmail('YOUR_EMAIL_ADDRESS', 'Backups have been removed from Google Drive', Logger.getLog()); } 

取消注释“ //”时

如何解决呢?

此处的屏幕截图:http : //i.imgur.com/fwAbHiY.png

拉法·吉列尔莫(Rafa Guillermo)

回答:

为了使用Drive.Files.remove()Apps脚本中方法,您需要激活Advanced Drive服务。

解析度:

在Apps脚本用户界面中,按Resources > Advanced Google Services如下所示单击

在此处输入图片说明

在新窗口弹出窗口中,向下滚动至Drive API,并确保v2在下拉列表已选中该窗口,单击右侧的滑块,以使其变为“ off”而不是“ off”,并变为“ on”:

在此处输入图片说明

在这里,您可以使用高级Google云端硬盘服务,例如Drive.Files.remove()

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

复制Google云端硬盘上的文件

来自分类Dev

在Google云端硬盘上删除的文件夹不会反映在Play Services云端硬盘API中

来自分类Dev

无法使用Google App脚本上传到Google云端硬盘上的子文件夹

来自分类Dev

使用Google API的Google云端硬盘上传文件

来自分类Dev

无法在js中的Google云端硬盘上上传图片

来自分类Dev

停用Google云端硬盘文件夹外部的Google云端硬盘上下文菜单

来自分类Dev

Google云端硬盘上传文件的大小限制

来自分类Dev

使用Adobe Acrobat在Google云端硬盘上打开.pdf文件

来自分类Dev

Google云端硬盘永久许可

来自分类Dev

如何从Google云端硬盘删除文件

来自分类Dev

Google云端硬盘文件如何没有“云端硬盘上存储的任何内容”?

来自分类Dev

是否可以获取Google云端硬盘文件的永久链接?

来自分类Dev

无法更新Google云端硬盘文件

来自分类Dev

Google云端硬盘-无法同步的文件

来自分类Dev

Apps脚本-自动从3天以上的Google云端硬盘中删除文件-获取文件列表

来自分类Dev

Google云端硬盘上传图片-数据未返回webContentLink-直接永久链接

来自分类Dev

Google云端硬盘上传图片-数据未返回webContentLink-直接永久链接

来自分类Dev

Google云端硬盘在同步时删除文件

来自分类Dev

使用Google云端硬盘SDK删除与我共享的文件

来自分类Dev

Google云端硬盘删除文件应用脚本getAllFilesForPaging

来自分类Dev

如何使用vb.net在Google云端硬盘上上传文件?

来自分类Dev

如何以编程方式在Android Studio中的Google云端硬盘上上传和下载任何文件

来自分类Dev

无法将文件上传到Google云端硬盘

来自分类Dev

无法将文字附加到Google云端硬盘文件中

来自分类Dev

无法共享文件(通过Gmail或Google云端硬盘)

来自分类Dev

Google云端硬盘可以上传文件,但无法查看

来自分类Dev

从Google云端硬盘导入文件

来自分类Dev

IMPORTDATA Google云端硬盘上的Google Sheet CSV

来自分类Dev

删除或删除云端硬盘中的特定文件

Related 相关文章

  1. 1

    复制Google云端硬盘上的文件

  2. 2

    在Google云端硬盘上删除的文件夹不会反映在Play Services云端硬盘API中

  3. 3

    无法使用Google App脚本上传到Google云端硬盘上的子文件夹

  4. 4

    使用Google API的Google云端硬盘上传文件

  5. 5

    无法在js中的Google云端硬盘上上传图片

  6. 6

    停用Google云端硬盘文件夹外部的Google云端硬盘上下文菜单

  7. 7

    Google云端硬盘上传文件的大小限制

  8. 8

    使用Adobe Acrobat在Google云端硬盘上打开.pdf文件

  9. 9

    Google云端硬盘永久许可

  10. 10

    如何从Google云端硬盘删除文件

  11. 11

    Google云端硬盘文件如何没有“云端硬盘上存储的任何内容”?

  12. 12

    是否可以获取Google云端硬盘文件的永久链接?

  13. 13

    无法更新Google云端硬盘文件

  14. 14

    Google云端硬盘-无法同步的文件

  15. 15

    Apps脚本-自动从3天以上的Google云端硬盘中删除文件-获取文件列表

  16. 16

    Google云端硬盘上传图片-数据未返回webContentLink-直接永久链接

  17. 17

    Google云端硬盘上传图片-数据未返回webContentLink-直接永久链接

  18. 18

    Google云端硬盘在同步时删除文件

  19. 19

    使用Google云端硬盘SDK删除与我共享的文件

  20. 20

    Google云端硬盘删除文件应用脚本getAllFilesForPaging

  21. 21

    如何使用vb.net在Google云端硬盘上上传文件?

  22. 22

    如何以编程方式在Android Studio中的Google云端硬盘上上传和下载任何文件

  23. 23

    无法将文件上传到Google云端硬盘

  24. 24

    无法将文字附加到Google云端硬盘文件中

  25. 25

    无法共享文件(通过Gmail或Google云端硬盘)

  26. 26

    Google云端硬盘可以上传文件,但无法查看

  27. 27

    从Google云端硬盘导入文件

  28. 28

    IMPORTDATA Google云端硬盘上的Google Sheet CSV

  29. 29

    删除或删除云端硬盘中的特定文件

热门标签

归档