List all files id inside a folder (no subfolders)

后端 未结 1 1187
长情又很酷
长情又很酷 2020-12-30 14:06

How can I list in a spreadsheet all files id that are located inside a folder ? I have the folder id and the folder contains less than 100 files in total.

fu         


        
相关标签:
1条回答
  • 2020-12-30 14:32

    This is quite simple if you read the documentation about how to write in a spreadsheet and how to get Drive's content.

    Here is an example you can customize if you want :

    function list_all_files_inside_one_folder_without_subfolders(){
      var sh = SpreadsheetApp.getActiveSheet();
      var folder = DriveApp.getFolderById('0B3qSFd3iikE3TERRSHExa29SU3M'); // I change the folder ID  here 
      var list = [];
      list.push(['Name','ID','Size']);
      var files = folder.getFiles();
      while (files.hasNext()){
        file = files.next();
        var row = []
        row.push(file.getName(),file.getId(),file.getSize())
        list.push(row);
      }
       sh.getRange(1,1,list.length,list[0].length).setValues(list);
    }
    
    0 讨论(0)
提交回复
热议问题