Skip to main content
hari_kdr
Known Participant
September 16, 2010
Answered

How to save as AI file with PDF compatability at the same location?

  • September 16, 2010
  • 1 reply
  • 7245 views

Hi Guys,

Requesting for script. Here are the details..

I  do have lot of AI files (from different paths) which are do not have PDF compatability switch  on. So now I am looking for script that all the files should save as at  the same place (over write) and should switch on the PDF compatability  switch on.

I tried with Action script, But the problem  is, action scripting is recording the path where I saved first time.  That means, all the files are save as into recorded path. This makes me  some what confusion, because source file will be 1 and save file with PDF  1. So in total 2 files will create which is not good.

So I am  requesting you that script schould overwirte at the same path and should  switch on the PDF compatability.

FYI: Using Adobe CS4...

If you help for this, it is really greatful for me.

Thanks in advance...

Regards

HARI

This topic has been closed for replies.
Correct answer Muppet_Mark-QAl63s

It works as Mark has said. It is set up to ask you where is the folder of files to process and then goes through and does each, replacing the originals in the folder. At least it does for me. On the side, Mark how would you put in a print statement so that the file would print to the default printer?


Larry, I don't do very much in the way of printing directly from either Illustrator or Photoshop most of this gets placed in ID for me and then output. Rather than set up lots of options in script I would make myself a bunch of print presets where I would set printers paper sizes etc. I think you can then just use the print command and pass this the name of a preset. Im at home where I don't have access to a printer so I can't say for sure. Im glad the the script above also worked for you… I've not gone totally mad just yet then…

If you have any presets saved then this would show you the string names that you should be able to use…

alert(app.printPresetsList.join('\r'));

To print Im guessing that you could simply do…

var docRef = app.activeDocument; var myPrint = new PrintOptions() myPrint.printPreset = app.printPresetsList[2]; docRef.print(myPrint);

This would of cause mean there needs to be 3 or more presets…

1 reply

Muppet_Mark-QAl63s
Inspiring
September 16, 2010

Please test this on some none important directories of files. It would appear to work for me finding just the AI files to open and re-save. Wouldn't like to set something off trawling through folders n it not be right… Should you wish to override the app's dialogs then un-comment those lines you will not be warned about missing links and such alike… Also Change the value to 14 for CS4 compatibility where indicated…

#target illustrator var df = new Folder('~/Desktop'); var topLevel = Folder.selectDialog('Please choose your Top Level Folder…', df).fsName; var fileList = new Array(); fileListRecursive(topLevel, /\.ai$/i); if (fileList.length > 0) {      main();      } else {      alert('This Folder or sub folders contained NO Illustrator AI files?');      } function main() {      with (app) {           while (documents.length) {                  activeDocument.close(SaveOptions.PROMPTTOSAVECHANGES);             }           //var orginalUIL = userInteractionLevel;                //userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;                      for (var a = 0; a < fileList.length; a++) {                var docRef = open(fileList);                with (docRef) {                     var aiOptions = new IllustratorSaveOptions();                     aiOptions.compatibility = Compatibility.ILLUSTRATOR12; // Change to 14 for CS4                     aiOptions.pdfCompatible = true;                               aiFilePath = new File(fullName);                     saveAs(aiFilePath, aiOptions);                     close(SaveOptions.DONOTSAVECHANGES);                }           }                     //userInteractionLevel = orginalUIL;      } } function fileListRecursive(f, exp) {                var t = Folder(f).getFiles();      for (var i = 0; i < t.length; i++) {           if (t instanceof File && RegExp(exp).test(t.fsName)) fileList.push(t);           if (t instanceof Folder) fileListRecursive(t.fsName, exp);      } }

Larry G. Schneider
Community Expert
Community Expert
September 16, 2010

Mark,

How can you overwrite the file if it is open in AI? Won't this throw a system error?

Muppet_Mark-QAl63s
Inspiring
September 16, 2010

Larry, the script performs a 'saveAs' where I pass the same file path as the file Illustrator opened but with different save options. The same thing can be done in the GUI but you would be prompted by the GUI to 'replace' then pass new options which will overwrite file…? Did a test of this throw you any errors as Im not seeing any here?