我尝试创建一个关于它们的简单脚本,我可以在 GDrive 中计算我的文件。问题是:脚本yount文件但不是全部:
搜索参数:类型:电子表格所有者:我脚本:2,浏览器:65 搜索参数:类型:文档所有者:我脚本:1,浏览器:59
//Quelle: https://developers.google.com/drive/api/v2/ref-search-terms
//Quelle: https://developers.google.com/apps-script/reference/base/mime-type
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("GDrive");
sheet.clear()
for (var i = 1; i <= 2; i++) {
if (i == 1) {var sFT = "document";}
if (i == 2) {var sFT = "spreadsheet";}
if (i == 1) {var sTXT = "GDocs";}
if (i == 2) {var sTXT = "GSheets";}
var files = DriveApp.searchFiles('"me" in owners and mimeType contains "' + sFT + '"');
let count = 0;
if (count == 0) {sheet.getRange(i,1).setValue(sTXT);}
if (count == 0) {sheet.getRange(i,2).setValue("0");}
while (files.hasNext()) {
var file = files.next();
count = count +1;
sheet.getRange(i,1).setValue(sTXT);
sheet.getRange(i,2).setValue(i);
}
}
}
有没有人可以帮助一个示例脚本?
谢谢