Hi Steve,
Try now.
Array.prototype.contains = function(k) { for(var i=0; i < this.length; i++) { if(this[i] === k) { return true; } } return false; } var _layers = [ "BaseArtwork", "MagentaVariables", "PreprintedText", "OtherVariables"]; var match = []; var ly = app.activeDocument.layers.everyItem().getElements(); if(ly.length == 4){ for (i=0; i<ly.length; i++) { if (_layers.contains(ly[i].name)) { match.push(i); } } } else { alert ("Layer count shouldn't be less or more than 4"); exit(); } if(match.length == 4) { var myJobOptionName = "[Press Quality]"; var myOutFolderPathName = "/Users/wleastudio/Desktop/Watched Folder/Out/"; var myPDFFilePath; var InDJobOption = app.pdfExportPresets; myPDFFilePath = myOutFolderPathName+"/"+app.documents[0].name.split(".indd")[0].split(".INDD")[0]+".pdf"; app.documents[0].exportFile (ExportFormat.pdfType, myPDFFilePath, false, myJobOptionName); } else { alert ("Check Layer names"); exit(); }
Regards,
Chinna