I'm trying to run the following script and populate all rows which match the file name (test1.pdf) in google drive folder. There are multiple rows which has the same file name, so I need to bring the same link to each row if it matches.
I tried the following code, but it does not work if there are blank rows in between the rows. Would appreciate your help on this. Thanks in advance.
Expected Result : Match the names in Column K and populate hyperlink in Column M in respective row, if "Yes" is not mentioned in COlumn N in the row. (There are blank rows in between these rows)
function myGDriveInt() {
var folderId = 'myfileid';
var folder = DriveApp.getFolderById(folderId)
var source = SpreadsheetApp.getActiveSpreadsheet();
var sheet = source.getSheetByName('Sheet1');
var RowSize=sheet.getRange('K:K').getValues().filter(String).length;
var file_name=sheet.getRange('K3:K'+RowSize).getValues()
var file_checker=sheet.getRange('N3:N'+RowSize).getValues()
for (i = 0; i < file_name.length; i++) {
if (file_checker[i][0]=="Yes"){continue;}
var files = folder.getFilesByName(file_name[i][0])
while (files.hasNext()) {
var childFile = files.next();
var file_url = childFile.getUrl()
sheet.getRange(i+3,13).setValue(file_url);
} // while
} //for
} // function