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?
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..
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.
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 );
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!