0

I want to know if there's any way to fetch google drive links through SQL and/or Looker from Google Drive from a particular folder and show them in Google Drive. For example: if there's a folder Named 'User' ---> and in it, there are many folders with unique IDS for every user.

I implemented a script in Google Drive but it leaves a few cells empty ( i.e does not fetch a few Google Drive Links).

function onOpen() {
  var sheet = SpreadsheetApp.getActive();
  var menu = [{name: "Get Folder Links", functionName: "getFolderLinks"}];
  sheet.addMenu("Custom Menu", menu);
}

function getFolderLinks() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 3;
  var data = sheet.getRange(startRow, 7, sheet.getLastRow() - startRow + 1, 1).getValues();
  
  for (var i = 0; i < data.length; i++) {
    var folderName = data[i][0];
    Logger.log(folderName);
    var folderIterator = DriveApp.getFoldersByName(folderName);
    if(folderIterator.hasNext()) //check if the folder exists
    {
        var link = folderIterator.next().getUrl();
        sheet.getRange(i+startRow, 15).setValue(link);
    } else 
    {
      Logger.log("Folder not exist: " + folderName);
    }
  }
}

Thank you

  • Guess, not possible to directly fetch Google Drive links through SQL, as Google Drive is a cloud storage service that is not directly integrated with SQL databases. However, you may be able to retrieve Google Drive links through a web application that has access to the Google Drive API, and then store those links in a SQL database. – Pranav Bilurkar Mar 03 '23 at 07:09
  • Do you have a sample of what the file tree looks like? What type of files are the ones missing the links? – Daniel Mar 03 '23 at 19:29
  • @daniel, the links are of the folders only. – Raman Singh Mar 07 '23 at 07:45

0 Answers0