[英]Google Apps Script - MAX EXECUTION TIME
I'm on GSuite Business and i have made a Google Apps Script for read the content on a GDrive folder and write on Column A the name of the file and on Column B the GDrive Link of the file.我在 GSuite Business 上,我制作了一个 Google Apps 脚本,用于读取 GDrive 文件夹上的内容,并在 A 列上写下文件的名称,在 B 列上写下文件的 GDrive 链接。 I have about 8800 Files on this folder and i go over the 30 minutes execution time quota.我在这个文件夹上有大约 8800 个文件,并且我在 30 分钟的执行时间配额上是 go。 at this time i don't have idea to solve this problem.. I past here my script...在这个时候我不知道解决这个问题..我过去了我的脚本......
This script are useful for see the list of images of the product for sync with my ecommerce.此脚本可用于查看与我的电子商务同步的产品图像列表。
function ImageDatabaseUpdate() {
//read file on my drive foldeer -> 06 - usato fine serie
var foldername = '06 - Usato e Fine serie';
var folderlisting = 'Database GTLG ';
var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
var contents = folder.getFiles();
var contents = folder.getFiles();
//Set file id and sheet Immagini
var ss = SpreadsheetApp.openById("1ok2tfpLFRHE6I4ehR9lfsLwtFy1UfTdJqbi-NCqGVS0");
var sheet = ss.getSheetByName('immagini');
//Write heading on first sheet row
sheet.appendRow(['name','link']);
var file;
var name;
var link;
var row;
//start reading and writing
while(contents.hasNext()){
file = contents.next();
name = file.getName();
link = file.getUrl();
sheet.appendRow([name, link]);
}
}
Your code goes into an infinite loop because you need contents.next()
to move to the next file.您的代码进入无限循环,因为您需要contents.next()
移动到下一个文件。 Since the folderIterator
doesn't increment, while(contents.hasNext())
will continue forever.由于folderIterator
不会增加, while(contents.hasNext())
将永远持续下去。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.