title: How do I make copy of spreadsheet and save it to particular folder?
body: <p>I'm working with Google App Script. I am trying to:</p>
  
  <ol>
  <li>Make a copy of a spreadsheet</li>
  <li>Give the copy a particular file name, and </li>
  <li>Save it to a particular folder.</li>
  </ol>
  
  <p>It seems to me that the code below should work, but it doesn't.  It <strong>does</strong> accomplish tasks 1 and 3 - that is, it makes a copy and saves the copy to my desired folder.  However, it does not save the file with the file name I specify.  Instead, it saves it as "Copy of [original spreadsheet filename]." To do this, I am using <a href="https://developers.google.com/apps-script/reference/drive/file#makeCopy(String,Folder)" rel="noreferrer"><code>File#makeCopy</code></a></p>
  
  <p>(Note: I know this question has been answered before, but I believe it has not been answered since Google sunset the DocList service.)</p>
  
  <p>When I made this simplified MCVE, I found that it works as expected:</p>
  
  <pre><code>function saveAsSpreadsheet() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet();
    var destFolder = DriveApp.getFolderById("xxxxxxxxxxxxxxxxx");
    DriveApp.getFileById(sheet.getId()).makeCopy("desired file name", destFolder);
  } //END function saveAsSpreadsheet
  </code></pre>
  
  <p>However, my original code does not - the copy's name is wrong:</p>
  
  <pre><code>function saveAsSpreadsheet() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet();
    var buildingNameAddress = sheet.getRangeByName('buildingNameAddress').getValue();
    Logger.log(buildingNameAddress); //Logs correct string
    var destFolder = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxx");
    DriveApp.getFileById(sheet.getId()).makeCopy(buildingNameAddress, destFolder);
  }
  </code></pre>