Skip to content

Get all files in Google drive shared link.

About:

You have lots of files in the google drive, and you want to share all of them at once. Then get the file name and shared link in google sheets to use later with excel

 

Steps:

  1. Upload all files to a folder in google drive
  2. Open the desired Google Drive folder and get its ID in the URL from the browser location bar: https://drive.google.com/drive/u/0/folders/<id>
  3. Open a new Google Sheet and navigate
    1. Tools > Script ditor. In the new script, paste the following script:

 

 

Code:

function myFunction() {

  var ss=SpreadsheetApp.getActiveSpreadsheet();

  var s=ss.getActiveSheet();

  var c=s.getActiveCell();

  var fldr=DriveApp.getFolderById(“folderID”);

  var files=fldr.getFiles();

  var names=[],f,str1,str2;

  while (files.hasNext()) {

    f=files.next();

    str1=’=text(“‘ + f.getUrl() + ‘”,”‘ + “” + ‘”)’;

    str2=’=text(“‘ + f.getName() + ‘”,”‘ + “” + ‘”)’;

   

    names.push([str1],[str2]);

  }

  s.getRange(c.getRow(),c.getColumn(),names.length).setFormulas(names);

}

 

 

  1. Replace folderID with step 2
  2. Run the script

 

 

It will list in the google sheet file link, and file name