download files from link in a column of a sheet

Skip to first unread message

carmelo di blanco pontillo

Jan 30, 2023, 7:05:59 AMJan 30
to Google Apps Script Community
Hello guys i am new here and new about app script.

I want to know if is possible to rename(with a name of a cell) and download(to google drive) a variable number of files from a spreadsheet that contain external links?
here an example file. In the sheet "APPOGGIO DATABASE" there are link to download (column F), to rename with the column A

there in app script is a code, but it download just the first file. i want that it will download all file in the column F, doesn't metter if there are 2 or 200 files.


Jan 30, 2023, 12:26:51 PMJan 30
to Google Apps Script Community
Hi Carmelo,

Your script create 1 folder (named as data in first row) with 3 files (one of each non-empty row). Depending on what you want you have to:
- 1 nolder x N files: Change de folder name as "people" or whatever you want (esaiest choice)
- N folders x 1 file: Put statements that create folder inside a loop (very similar at files loop or adapting it) 

If you choose 1 folder per row anf 1 file per folder option you can try with this:

var rowDB = ss.getRange("A:F").getValues().filter(f=>f[5] !="");
  for(i in rowDB){   
    var name = rowDB[i][0] + " " + rowDB[i][1] 
    var folders =  DriveApp.getFoldersByName(name)
    if (folders.hasNext()) {
      folder =;
    } else {
      folder = DriveApp.createFolder(name);
    var url = rowDB[i][5].toString()        
    var file = UrlFetchApp.fetch(url).getBlob().setName(name)
Reply all
Reply to author
0 new messages