title: How to Import Google Drive Sub-Folder URL to Google Sheet
body: <p>I'm trying to import the Sub-folder's (Not Files) Name &amp; URL which is in the Main Folder to Google Sheets</p>
  <p><a href="https://i.stack.imgur.com/hKr9k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hKr9k.png" alt="enter image description here" /></a></p>
  <p>I tried working on this code but it didn't help me to achieve my task.</p>
  <pre><code>var SS = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&quot;Sheet3&quot;);
      
     
      function getFolderArray(folderId){
        var folder = DriveApp.getFolderById(folderId);
        var Folders = folder.getFolders();
        var FolderList = [];
        
        //Loop though Folders and add names and urls to the array
        while (folder.hasNext()){ 
          var Folder = Folders.next();
          var FolderName = Folder.getName();    
          var FolderUrl = Folder.getUrl();
          FolderList = FolderList.concat([[FolderName, FolderUrl]]);
        }
         //See returned FolderList in a log
        //Logger.log( FolderList ) //Preview Returned Array      
        return FolderList
        
       
      }
      
        
      //Prints any 2D array to a range that starts with the selected cell
      function printArrayToSelection(twoDimArr){  
        var firstCell = SS.getActiveCell();
        var lastCell = firstCell.offset(twoDimArr.length - 1, twoDimArr[0].length - 1);
        var destinationRange = SS.getActiveSheet().getRange(
          firstCell.getA1Notation() + ':' + lastCell.getA1Notation());
        destinationRange.setValues(twoDimArr);
        
      }
      
      //Print the actual data
      function printFolderArray(){
        printArrayToSelection(getFolderArray('0B4-wws2P3gUhcExqWEI0VTlrNm8'));
      }
  </code></pre>
  <p>Can I know what went wrong?</p>