Google Drive – List all files id inside a folder (no subfolders)
If you want to list in a spreadsheet all files id that are located inside a folder (no subfolders).
function list_all_files_inside_a_folder(){
var sh = SpreadsheetApp.getActiveSheet();
var folder = DriveApp.getFolderById('1a1SkFgbMIr_8z1HnZvIpUPcOQ0NWp3HL'); //Change the folder ID here
var list = [];
sh.clear();
list.push(['File Name','File ID','Size(MB)']);
var files = folder.getFiles();
while (files.hasNext()){
file = files.next();
var row = []
row.push(file.getName(),file.getId(),file.getSize()/1048576)
list.push(row);
}
sh.getRange(1,1,list.length,list[0].length).setValues(list);
}