I think that your base script should like this (without comments): //@target illustrator main(); function main() { var aitFile = File('~/Desktop/Illustrator Hot Folder/Add Zund-Print-Save/ZTemplate/Zund Setup.ait'); app.open(aitFile); var foldPath = '~/Desktop/Illustrator Hot Folder/Add Zund-Print-Save/IN' var fold = Folder(foldPath); var files = fold.getFiles(); var file, newImg, doc, artboards, img; for (var j = 0; j < files.length; j++) { file = files ; newImg = activeDocument.placedItems.add(); newImg.file = file; newImg.position = [200, -300]; } doc = app.activeDocument; artboards = doc.artboards; img = doc.placedItems[0]; img.left = 0; img.top = 0; artboards[0].artboardRect = [0, 0, img.width, -(img.height)]; app.executeMenuCommand('fitall'); addThroughCut(); wrapper('BRINGTOFRONT'); prnt(); saveAsPdf('Proof' + app.activeDocument.placedItems[0].file.name); wrapper('SENDTOBACK'); saveAsPdf(app.activeDocument.placedItems[0].file.name); app.documents[0].close(SaveOptions.DONOTSAVECHANGES); files = myFolder.getFiles(); for (var i = files.length - 1; i > -1; i--) { files.remove(); } /** * LIBRARY * */ function addThroughCut() { var doc = app.activeDocument, layers = doc.layers, swatches = doc.swatches, artboards = doc.artboards, bleed = 18, img = doc.placedItems[0], docSize = [img.width, img.height], artLay, cutLay; img.left = 0; img.top = 0; artboards[0].artboardRect = [0, 0, docSize[0], -(docSize[1])]; _initLayers(); _addThroughCut(); layers["Layer 1"].remove(); function _initLayers() { artLay = layers.add(); artLay.name = "Artwork"; img.moveToBeginning(artLay); cutLay = layers.add(); cutLay.name = "Through Cut"; } function _addThroughCut() { var cutLine = cutLay.pathItems.rectangle(-(bleed), bleed, docSize[0] - (bleed * 2), docSize[1] - (bleed * 2)); cutLine.filled = false; cutLine.strokeColor = swatches["Through Cut"].color; } } function wrapper(zOrdMeth) { var doc = app.activeDocument; var layers = doc.layers; var artLayer = layers["Artwork"]; var thruCutLayer = layers["Through Cut"]; thruCutLayer.zOrder(ZOrderMethod[zOrdMeth]); } function prnt() { var storeUserInteract = userInteractionLevel; var d = activeDocument; var jbOpts = new PrintJobOptions(); var opts = new PrintOptions(); opts.printPreset = "JEFF_HP"; opts.jobOptions = jbOpts; userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; d.print(opts); userInteractionLevel = storeUserInteract; } function saveAsPdf(targFileName) { var destFolder = null; try { if (app.documents.length > 0) { destFolder = Folder('~/Desktop/Illustrator Hot Folder/Add Zund-Print-Save/OUT'); if (destFolder !== null) { var options, i, sourceDoc, targetFile; options = _getOptions(); options.pDFPreset = "Dynagraphics PDF - Flat - Layers" for (i = 0; i < app.documents.length; i++) { sourceDoc = app.documents; targetFile = _getTargetFile(targFileName, '.pdf', destFolder); /// This is the line I added "Proof+" to the name that's not working sourceDoc.saveAs(targetFile, options); } } } else { throw new Error('There are no document open!'); } } catch (e) { } function _getOptions() { var options = new PDFSaveOptions(); options.pDFPreset = "Dynagraphics PDF - Flat - Layers" return options; } function _getTargetFile(docName, ext, destFolder) { var newName = ""; if (docName.indexOf('.') < 0) { newName = docName + ext; } else { var dot = docName.lastIndexOf('.'); newName += docName.substring(0, dot); newName += ext; } var myFile = new File(destFolder + '/' + newName); if (myFile.open("w")) { myFile.close(); } else { throw new Error('Access is denied'); } return myFile; } } } You are running the scripts through ExtendScriptToolkit and see where errors occur? ps. Can you format the code in the same way? Thank you!
... View more