I have 100 Google Sheet files in one folder of Google Drive. Each Google sheet file has 10 sheets (A,B,C,D,E,F,G,H,I,J). I wanted to append all 100 Google Sheet files into one Google Sheet appending data from "B" sheets of all the 100 files. All the sheets has same columns. I have tried the below code. But it is pulling all "B" sheets from 100 files in to one Google Sheet but not appending the data from sheets into one.
function myFunction()
{
var myFolder = DriveApp.getFolderById("1ZtxfMNDn3uFhCcdcp5unfmTwUIJ_3fZK");
var spreadSheets = myFolder.getFilesByType("application/vnd.google-apps.spreadsheet");
var newSpreadSheet = SpreadsheetApp.create("MergedNew");
while(spreadSheets.hasNext())
{
var sheet = spreadSheets.next();
var spreadSheet = SpreadsheetApp.openById(sheet.getId());
for(var y in spreadSheet.getSheets())
{
spreadSheet.getSheets()[y].copyTo(newSpreadSheet);
}
}
}