I have a lot of files on a team/shared drive that I want to generate links of. I managed to do it, but I also want to make the links viewable by anyone with the link. When I added the script to change each files sharing access, it always gives me Maximum time exceeded error or something. Here is the code, by the way, I aint really good on coding so this is mostly copy paste from here and there:
function myFunction() {
var ss=SpreadsheetApp.getActiveSpreadsheet();
var s=ss.getActiveSheet();
var c=s.getActiveCell();
var fldr=DriveApp.getFolderById("FOLDER_ID_HERE");
var files=fldr.getFiles();
var names=[],f,str;
while (files.hasNext()) {
f=files.next();
// f.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.VIEW); //
str='=hyperlink("https://drive.google.com/uc?id=' + f.getId() + '&export=download","' + f.getName() + '")';
names.push([str]);
}
s.getRange(c.getRow(),c.getColumn(),names.length).setFormulas(names);
}
I can even settle for a script that makes all of the files accessible by anyone. This script works without the one in comments. But I need that to make all the generated links accessible by anyone :(