I have a slide deck where each slide needs to be converted into individual slides. I found this script for splitting a deck into single slides and saving them (This code was provided by @Tanaike here):
function myFunction() {
const presentationId = "###"; // Please set the Slides ID.
SlidesApp.openById(presentationId).getSlides().forEach((s, i) => {
const newSlide = SlidesApp.create(`page${i + 1}`);
newSlide.appendSlide(s);
newSlide.getSlides()[0].remove();
});
}
The script names the slides 1, 2, 3, etc. and saves them into My Drive. I'd like to be able to name each slide based on names listed in a spreadsheet range (e.g. Slide 1 = "Introduction", Slide 2 = "Agenda") and save all of the slides into a specified Google Folder ID.
You can try with the following, it worked for me.
function myFunction() {
const presentationId = "slidesID"; // Please set the Slides ID.
var slides = SpreadsheetApp.openById("sheetID").getRange("Sample!A1:A3").getValues(); //Specify the sheet ID and the range where you have the names for each slide
SlidesApp.openById(presentationId).getSlides().forEach((s, i) => {
const newSlide = SlidesApp.create(slides[i]);
newSlide.appendSlide(s);
newSlide.getSlides()[0].remove();
var fileID = newSlide.getId();
var folderID = DriveApp.getFolderById("folderID"); //Specify the folder ID where you want to move the new slides
DriveApp.getFileById(fileID).moveTo(folderID)
});
}