I have a slide under URL:https://docs.google.com/presentation/d/1IGsd
which is a source slide and cannot be "touched". Now, I want to programmatically make a copy of this source slide every week and save it under the name "slide_{timestamp}"
in my root google drive folder to do manipulations on those.
Can someone help on how to approach this or existing code which may help? Thanks!
Go to your source slide, click on Tools => Script editor and copy-paste the following function:
function copySourceSlide() {
const presentation = SlidesApp.getActivePresentation();
const destFolder = DriveApp.getFolderById("folderId");
DriveApp.getFileById(presentation.getId()).makeCopy(`slide_${new Date().toLocaleString()}`, destFolder);
}
This code will create a copy of the source slide with a name slide_datetime
to a particular folder of your choice, indicated by folderId
.
If you want to create a weekly trigger event for a particular day and hour, you can do it either manually or programmatically like that:
function createTimeDrivenTriggers() {
// Trigger every Monday at 09:00.
ScriptApp.newTrigger('copySourceSlide')
.timeBased()
.onWeekDay(ScriptApp.WeekDay.MONDAY)
.atHour(9)
.create();
}
References: