google apps script - List all files id inside a folder (no subfolders) -


how can list in spreadsheet files id located inside folder ? have folder id , folder contains less 100 files in total.

function list_all_files_inside_one_folder_without_subfolders(){ var sh = spreadsheetapp.getactivesheet(); var folder = driveapp.getfolderbyid('0sdfsfd......sfdsdftg'); // change folder id  here  // logger.log('folder name: ' + folder.getfiles()); sh.getrange(1,1,1,1).setvalues('fileid'); } 

thanks

this quite simple if read documentation how write in spreadsheet , how drive's content.

here example can customize if want :

function list_all_files_inside_one_folder_without_subfolders(){   var sh = spreadsheetapp.getactivesheet();   var folder = driveapp.getfolderbyid('0b3qsfd3iike3terrshexa29su3m'); // change 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); } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -