The names in your sample were files without extension. Now they have extensions. That could cause the problem. And the names contain spaces, which is a problem with the search
I wrote.
Changing
const targetRec = app.search(`name: ${name}`)
to
const targetRec = app.search(`name: "${name}"`)
Should fix that. And using filename
instead of name
in that line might make it find the record with an extension. But then they might not be found if you use the original format in the CSV, which didn’t contain the extension.
And the first row of the CSV is skipped by the script. That was my error. Change the line
for (let i = 2; i <= rowCount; i++)
to
for (let i = 1; i <= rowCount; i++)
(i.e. 1 instead of 2).