Copy link to clipboard
Copied
I've found a Illustrator cc script that i've adapted and added to make my life 5 times easier. To make it 6 times easier i'd love to save it to a destination folder chosen in the diaglog box at the start. For the life of me I can't work out what to do. Everything I try using " Folder.selectDialog" either saves it in the folders current location or in recent location.
What the current script does is:
Saves .ai file out as 3 separate files based on some presets with the following extentions .ai OL.pdf and OL_LR.pdf
#target illustrator
#targetengine "main"
for (x=0;x<app.documents.length;x++)
{
var workingDoc = app.documents
; var workingDocFile = workingDoc.fullName;
var HighPreset = 'High Res';
var LowPreset = 'Low Res';
// populate these with your settings
var aiFile = new File(workingDocFile.toString().replace(".ai","_OL.ai"));
workingDoc.saveAs(aiFile);
var lowResOpts = new PDFSaveOptions();
lowResOpts.pDFPreset=LowPreset;
var highResOpts = new PDFSaveOptions();
highResOpts.pDFPreset=HighPreset;
var lowResFile = new File(workingDocFile.toString().replace(".ai","_OL_LR.pdf"));
workingDoc.saveAs(lowResFile,lowResOpts);
var highResFile = new File(workingDocFile.toString().replace(".ai","_OL.pdf"));
workingDoc.saveAs(highResFile,highResOpts);
}
Any help would be much appreciated.
Thanks, Phil
Copy link to clipboard
Copied
Hi Phil
Making PDFs seams like shooting in the dark. my codes work today or in this minute and then dont tomorrow or in the next minute.
anyway I use: saveName = workingDoc.path.fsName rather than: .fullName.
This works for me.
Also I am not so fancy with the .replace() so I just write saveName = saveName + "something". I am not saying this is elegent but maybe it is safer?
Best,
Dane
Copy link to clipboard
Copied
the .replace() function used in the example does something different than your example of
saveName = saveName + "something"
in your example, if saveName was already "myFile.ai", your code would result in "myFile.ai.something". the regex replace() function actually changes a part of the given string if necessary. I don't think there's anything "dangerous" about using replace over standard string concatenation. they are simply different. in fact one might argue that regular concatenation COULD be more dangerous because it will always change the resulting string even if you didn't want to..
Copy link to clipboard
Copied
Thanks for the replys! I managed to work something out in the end and simplified it a bit. Heres the code incase anyone else needs it.
#target illustrator
function PDFSaver(){
var doc = app.activeDocument;
var destFolder = Folder(app.activeDocument.path).selectDlg('Select the folder where you want to save the PDF files.');
var LowResopts = new PDFSaveOptions();
var HighResopts = new PDFSaveOptions();
LowResopts.pDFPreset = "Low Res";
HighResopts.pDFPreset = "High Res";
doc.saveAs(File(destFolder + "/" + doc.name.replace(".ai", "_OL.ai")));
doc.saveAs(File(destFolder + "/" + doc.name.replace("_OL.ai", "_OL.pdf")), HighResopts);
doc.saveAs(File(destFolder + "/" + doc.name.replace("_OL.pdf", "_OL_LR.pdf")), LowResopts);
alert( 'Action Completed Succesfully, Yayyyy! Files saved in ' + destFolder );
};
PDFSaver();
I also combined this into an action with illustrator so it outlines all text then runs this script by pressing a hot key. My life is now 7 times easier!