title: Google Apps Script Remove Folder From Drive
body: <p>I have a very simple script that runs in a Spreadsheet and triggers an event on Form Submit. Basically what happens is when a new record is added to the spreadsheet a folder is created in a designated sub-folder. The script works 100% but the end result is a folder in the root of My Drive AND a folder in the destination sub-folder.</p>
  
  <p>The spreadsheet columns are A = Timestamp, B = Organisation Name &amp; C = Target Parent Folder (into which the new folder will be placed).</p>
  
  <p>I need to then delete the folder located in the root and leave the other folder where it is.</p>
  
  <p>Alternatively I need to place the designated folder directly into its target folder.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>  function newOrgFolder(){
        var ss = SpreadsheetApp.getActiveSpreadsheet();
        var sheet = ss.getActiveSheet();
        var lastRow = sheet.getLastRow();
        var folderCell = sheet.getRange(lastRow, 2);
        var folderName = folderCell.getValues();
        var contractStatusRange = sheet.getRange(lastRow, 3);
        var contractStatus = contractStatusRange.getValues();
  
        DriveApp.createFolder(folderName);
  
        var source = DriveApp.getFoldersByName(folderName).next();
        var folder = DriveApp.getFoldersByName(contractStatus).next();
  
        folder.addFolder(source);
  
  
  }
  </code></pre>
  
  <p>Can anyone let me have the correct code to remove the folder from root and leave the copied folder where it is?</p>
  
  <p>Or let me know how to place the new folder directly into the target folder without having it appear in root as well.</p>