need script to export pages with field from data merge
I am trying to save 800+ certificates from a data merge with the first data cell (full name). I'm new to scripts so I might not have added this correctly. My excel file has the names in the 1st column. This is the script I added but it does not work. I only changed the text in red. These can either be jpg or pdf files.
I posted this as a reply to someone else's thread a couple of days ago but have not go any responses. These need to get done, so if I don't receive a response in the next day or so, I'll be spending several hours renaming over 800 files individually.
//http://www.scriptopedia.org/index.php?post/custompdfexport.jsx.html
//use some csv row to rename a bunch of pdf files accordingly:
var csv=File(Folder.desktop+"/Webinar_Stats_for_CE_Credits_221201 - Merge File for INDD.csv");
var myPDFFolder = Folder(Folder.desktop+"/pdfs");
var names = getNamesFromCSV(csv);
if(csv.exists && myPDFFolder.exists){
var files = myPDFFolder.getFiles();
if(files.length==names.length){
for(var i=0; i<files.length; i++){
files[i].rename(files[i].parent+"/"+names[i]+".pdf");
}
}
}
function getNamesFromCSV(csv){
if(csv.exists){
csv.open('r');
var content = csv.read();
var namesArr = [];
content=content.split("\n");
for(var j=0; j<content.length; j++){
namesArr.push(content[j].match(/^(.[^\n]+)/i)[1]);
}
csv.close();
return namesArr.slice(1,namesArr.length);
}
return false;
}
This is my error message:

Thanks for any advice.
