title: I need to list all the files in subfolders using google script
body: <p>I am trying to make a summary sheet for all files in a folder. This is what I have so far, but I cannot figure out how to list the files in the subfolders of "folderid". Any ideas would be greatly appreciated.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//GLOBAL VARIABLES
  
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
  
  function onOpen() {
      ss.getRange(1, 1, 100, 10).clear({contentsOnly: true})
  
      var id = "folderid";
      var arr = [["CAPITAL PROJECT", "URLs", "OWNER"]];
  
      var f = DriveApp.getFolderById(id).getFiles()
      while (f.hasNext()) {
  
          var file = f.next();
          var name = file.getName()
          var url = file.getUrl()
          var own = file.getOwner().getName()
  
          arr.push([name, url, own]);
  
          ss.getRange(1,1, arr.length, arr[0].length).setValues(arr);
      }
  
      ss.getRange(2,1, arr.length, arr[0].length).sort(1)
  
      var second = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2")
      second.activate()
  }</code></pre>
  </div>
  </div>
  </p>