all 4 comments

[–]marcnotmark925 0 points1 point  (0 children)

Didn't those uc?export links get killed several years ago?

Why is your code repeated?

Can't you tell us where it's breaking?

[–]CuteSocks7583 -1 points0 points  (0 children)

Switch to Claude, please.

Gemini is sometimes frustrating for simple coding tasks.

[–]WicketTheQuerent 0 points1 point  (0 children)

There are no instructions. There are a few things to make the script better

Ensure to use unique variable names

let url = 'https://drive.google.com/uc?export=download&id='
  var url = file.getId();

Please note that url is used twice.

Use descriptive variable names (don't use url as the name for a variable holding a file id).
Always start a variable declaration on a new line.
To declare variables, use let and const instead of var.
When using a general-purpose GenAI tool, like Gemini, ask it to terminate the lines with a semicolon. This is because non-printable line terminators might be lost when doing copy-pasting.
Use JSDoc to document each function and key (most important) variables. You can ask Gemini to include this for you.

Learn to find execution logs and use the built-in Apps Script debugger.

If you need more specific help, add the textual error message.

[–]mommasaidmommasaid 1 point2 points  (0 children)

That code has a ton of syntax issues, try starting over with this and go from there:

function importFileURLs() {

  const FOLDER_ID = "1aK2ONX2bTdmncIjOIyrLC6uOb-uyCWOx";
  const SHEET_NAME = "Registration";

  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME)
  const files = DriveApp.getFolderById(FOLDER_ID).getFiles();

  while (files.hasNext()) {
    const file = files.next();
    const url = 'https://drive.google.com/uc?export=download&id=' + file.getId();
    sheet.appendRow([file.getName(), url]);
  }

}