A GAS function to get data of all folders in specific location in Google Drive.

A GAS function to get data of all folders in specific location in Google Drive.

Source : StackOverflow

function list_all_subfolders(){
  var ss = SpreadsheetApp.getActive();
  var config = ss.getSheetByName("ConfigFile");
  var folder_ID = config.getRange("B1").getDisplayValue(); 

/*
The ID of the parent folder is stored in the spreadsheet in cell B1 on the sheet "ConfigFile"
*/
  var folder = DriveApp.getFolderById(folder_ID); 
  var list = [];
  list.push(['Name','ID']);
  var folders = folder.getFolders();
  while (folders.hasNext()){
    folder = folders.next();
    var row = []
    row.push(folder.getName(),folder.getId())
    list.push(row);
  }
   config.getRange(1,15,list.length,list[0].length).setValues(list);
}