title: Google Script App - Save file in specific folder
body: <p>What I'm trying to do here with this script is to read the information of an specific sheet with one column and three rows, then create a txt file with these three rows and save it into an specific folder in drive.</p>
  
  <p>So far, with this little script I was able to create the file I wanted but it does it by default in the root folder.</p>
  
  <pre><code>function export() { 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); 
    var sheets = ss.getSheetByName("T2001D");
    var values = sheets.getDataRange().getValues();
    var text = "";
    for (var j in values)
    {
      text += values [j][0]+"\n";
    }
    var ff = DriveApp.createFile("T2001D",text,MimeType.PLAIN_TEXT);
    }
  </code></pre>
  
  <p>My latest attempt was this, I'm trying to make a copy of the file in the root into the folder "T2001D - Test" and then remove it from root. But I'm getting an error saying "No item with the given ID could be found, or you do not have permission to access it. (line 13, file "Code")"</p>
  
  <pre><code>function export() { 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); 
    var sheets = ss.getSheetByName("T2001D");
    var values = sheets.getDataRange().getValues();
    var text = "";
    for (var j in values)
    {
      text += values [j][0]+"\n";
    }
    var ff = DriveApp.createFile("T2001D",text,MimeType.PLAIN_TEXT);
    var fileID = DriveApp.getFilesByName("T2001D");
    var folderID = DriveApp.getFoldersByName("T2001D - Test");
    var file = DriveApp.getFileById(fileID).getName();
    var folder = DriveApp.getFolderById(folderID);
    var newFile = file.makeCopy(file, folder);
  }
  </code></pre>
  
  <p>I have manager access to the folder, so I don't think it's an issue of permissions. Do you guys have any ideas or suggestions to do this?</p>
  
  <p>And one more thing, I'm not a programer. I've created this frankenstein mostly by some examples I saw on this site and a little "reverser engineering" of mine. </p>
  
  <p>Thanks!</p>