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);
}

Leave a Reply

×

Your Cart

No products in the cart.
Start shopping

About Us

Royal Technologies is a System Integration house that supports Web Design, Web Hosting, Domain Registration, Search Engine Optimizing, IT Consulting, Remote or Telephone Support and Software Development. In simpler terms it’s an IT Company dealing in various aspects of implementation and maintenance of computerization. We have learnt from experience and have molded ourselves to be complete IT Company.

CONTACT US

Location

Copyright © 2008-2024 Royal Technologies. All rights reserved.
Development by Royal Technologies