I have a script but I wanted to rename the sheets at the same time it's being copied. If it can also return the link ID that would be awesome too!
function copySheets() {
for(i=0; i<146; i++){ //change the number to however many copies you want.
var drive=DriveApp.getFileById('SHEET ID LINK GOES HERE');
drive.makeCopy();
}
}
I am able to make the copies, but to rename 146 files is a lot of work. I want to run the script and inside the workbook, I have a List tab with the name of the files I want to put.
Any help is appreciated!
I understand that you want to create many copies out of a single Sheet, and you also need to return the new IDs. You can reach those goals easily by making small modifications into your script. The end result should look like this:
function copySheets() {
var originalFile = DriveApp.getFileById(
"{ SHEET ID }");
var newFiles = [];
for (i = 0; i < 146; i++) {
newFiles.push(originalFile.makeCopy("Copy #" + i).getId());
}
return newFiles;
}
That script will create new copies on loop and name them in order. After the creation is done the new ID is pushed inside an array. After the loop is done the function will return that array filled with all the new IDs.