I am a beginner at scripting, coding, and web design. I have been having questions regarding developing an Adobe Script that will Automatically open a PDF file I have (created in Illustrator CC 2015), Automatically change the name of two swatches to new names I have, then automatically Save with same file name plus "_Z.PDF" at the end and close the file.
Below is the code i developed with help from experts. It is designed for a Mac computer and is opened using ESTK. When I try activating, it says there is still an error in the part : var doc = app.open(f); What should I do about this? I have it underlined below too in bold italics.
function test()
{
// 1)
var thePath = "~/Desktop/";
var theFile = "test_swatch_change.pdf";
var f = new File(thePath + theFile);
var newFileName = theFile.replace(/\.pdf$/, "_Z.pdf");
var doc = app.open(f);
// 2)
doc.swatches.getByName('Kiss Cut').name = ('CutContourKiss-cut');
doc.swatches.getByName('Through Cut').name = ('CutContourThru-cut');
// 3)
var saveFile = new File(thePath + newFileName);
var saveOpts = new PDFSaveOptions();
doc.saveAs(saveFile, saveOpts);
// 4)
doc.close();
}
test();