extrobe
2/21/2017 - 10:53 AM

Save a copy of a file in a new folder

Save a copy of a file in a new folder

function SaveACopy(FileToCopy){

    // GUID of the folder we want to save the copy to
    var destFolder = DriveApp.getFolderById("0BwtjsOPtRiazS9U0UzlmWED8Wlk"); 
    
    // Create the new file name based on the current file + the date
    FileName = DriveApp.getFileById(FileToCopy).getName() + " - " + new Date()
    
    // Save the file in the right folder with the chosen name
    DriveApp.getFileById(FileToCopy).makeCopy(FileName, destFolder);
       
   } //END function saveAsSpreadsheet


function MainFunction () {
  
   var FileIdToUse = "1sMDMdQcP9HxwenDNQIJA9MTNnXV-4DEHU"
   SaveACopy(FileIdToUse)
  
}