// return list of files in a folder
function getListOfFilesInFolder(targetID) {
filesList="";
var parentFolder = DriveApp.getFolderById(targetID);
var files = parentFolder.getFiles();
while (files.hasNext()) {
var file = files.next();
filesList += file.getName()+ "|" + file.getId() + ",";
}
var output = filesList.replace(/,\s*$/, ""); //removes last comma
return ContentService.createTextOutput( output );
}
You can set this up in a script bound to a google sheet, and generate a list of the files to be placed in a set of columns and rows in that google sheet.
You can then download this list from the google sheet to the app
If you want to automate a bit more, you can create a google apps script web app, which will do all that for you.
// return list of files in a folder
function doGet(e) {
filesList=[];
var parentFolder = DriveApp.getFolderById(e.parameter.folderID);
var files = parentFolder.getFiles();
while (files.hasNext()) {
var file = files.next();
filesList.push([file.getName(),file.getId()]);
}
var output = JSON.stringify(filesList);
return ContentService.createTextOutput( output );
}
It will return a JSON stringified list of lists, like this:
Also i have not used folder id that is connected with my google account, The folder id is another's public folder id. Is it okay or i have to do with another's google account.??
Somebody suggested me to use this code:
function myFunction123() {
var foldername = 'Folder Name';
var folderlisting = 'listing of folder ' + foldername;
var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
var contents = folder.getFiles();
var contents = folder.getFiles();
var ss = SpreadsheetApp.create(folderlisting);
var sheet = ss.getActiveSheet();
sheet.appendRow(['name','link']);
var file;
var name;
var link;
var row;
while(contents.hasNext()){
file = contents.next();
name = file.getName();
link = file.getUrl();
sheet.appendRow([name, link]);
}
};
So i used that and its perfectly working for me...
Is it possible using the script you have provided? @TIMAI2