I have a folder that is constantly being upload with a new google sheet on fridays. I was wondering if there is a way to trigger a script to copy the name and the data of the new sheet in this forlder and place it in another location into a master sheet.
The name of the sheet is constantly been updated with the date of when it was upload. the master sheets name and location will never change.
function runsies() {
copyRange(
"the google sheet ID", // google ID of the master sheet
"the name of the sheet!A2:H", //name of the master sheet!, rnag to copy from mastersheet
"getNewestFileInFolder", //Destination
"detination!A2" // name of the Dump sheet! and the location of the dump file.
);
}
function copyRange(sourceRange, destinationID, destinationRangeStart) {
const sourceSS = SpreadsheetApp.openById(getNewestFileInFolder());
const sourceRng = sourceSS.getRange(sourceRange)
const sourceVals = sourceRng.getValues();
const destinationSS = SpreadsheetApp.openById(destinationID);
const destStartRange = destinationSS.getRange(destinationRangeStart);
const destSheet = destStartRange.getSheet();
const destRange = destSheet.getRange(
destStartRange.getRow(),
destStartRange.getColumn(),
sourceVals.length,
sourceVals[0].length
);
destRange.setValues(sourceVals);
SpreadsheetApp.flush();
};