I found a solution on how to reduce the execution time here but I'm unable to implement it through batching as discussed here. [question]:Google app script timeout ~ 5 minutes?
Sorry, I am completely new to scripts. The script below loops through all sheets and changes the sheetname to the value in A1.
function onEdit() {
var ss = SpreadsheetApp.getActive();
var allsheets = ss.getSheets();
// Array holding the names of the sheets to exclude from the execution
var exclude =["Sheet1","Sheet2","Sheet3","Article","Frontpage","Logos","Sheet4","Sheet5","Sheet6","Sheet10"];
for(var i=10;i<allsheets.length;i++) {
var sheet = allsheets[i];
var oldName = sheet.getName();
var newName = sheet.getRange(1,1).getValue();
if (newName.toString().length>0 && newName !== oldName) {
sheet.setName(newName);
// Stop iteration execution if the condition is met.
if(exclude.indexOf(sheet.getName())==-1) continue;
}
} // end of loop
} // end of function
How can I implement batching on the above script using the example below as a reference to reduce the number of service calls?
for (var i = 1; i <= 100; i++) {
SpreadsheetApp.getActiveSheet().deleteRow(i);
}
Do this:
SpreadsheetApp.getActiveSheet().deleteRows(i, 100);