'Duplicate File Multiple times and Rename the copies using list in Sheets

I'm trying to make multiple duplicates of a Google sheet, rename the copied documents using a roster in another google sheet document, then move them all to a specified folder in my drive. I've tried multiple script examples, but none of them meet my needs. I need a script that will make 60 copies of this document, then rename the copies using my roster in a different document from a column on a specific tab, then move the copies to my "Teachers" folder in drive.

Can anyone help?



Solution 1:[1]

I created the following script so you get the idea:

function createCopy()
{
  let file = DriveApp.getFileById("File ID"); // ID of the file you want to copy
  let sheet = SpreadsheetApp.openByUrl('Sheet URL').getSheetByName("Sheet1"); // URL and sheet name of the spreadsheet where the roster is.
  let range = sheet.getRange('A1:A'); // Range where the roster data is located
  let values = range.getValues();
  let folder = DriveApp.getFolderById("Folder ID"); // ID of the destination folder
  for(let i=0; i<values.length; i++)
  {
    file.makeCopy(values[i].toString(), folder);
  }
}

The script gets the list of names from a specific column of a specific sheet, then creates a copy with the name of each user and places the copy in the desired folder.

Reference:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fernando Lara