Getting ID's from google drive folder

Hi @Jasper_VIVISOL,
maybe this workflow can help you.KNIME_project – KNIME Hub
It calls a short Google Apps standalone script, which returns a JSON array with name, url and id of the files in the folder whose id you provide in the GET call.

function getFileList(folderId) {
  let folder=DriveApp.getFolderById(folderId);
  let files=folder.getFiles();
  let file_list=[], f, link;
  while (files.hasNext()) {
    f=files.next();
    file_list.push({"name": f.getName(), "url": f.getUrl(), "id":f.getId()})
  }
  return file_list;
}

function doGet(e) {
  if (e && e.parameter && e.parameter.id) {
    var folderId = e.parameter.id
   }
   else {
     var folderId = "<default folder id>"
  }
  // console.log(JSON.stringify(getFileList(folderId)))
  return(ContentService.createTextOutput(JSON.stringify(getFileList(folderId)))).setMimeType(ContentService.MimeType.JSON)
}

You just have to write into the Table Creator the url of the script and the id of the folder you want to read (current values must be replaced)
The final result is a table like this one
immagine

When you deply your web app remember to “allow anyone to access”

Hope the workflow will help you

5 Likes