• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can I Save different File Formats via a Script in Illustrator

Engaged ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

Hello, I am working off of PDF files, and depending on what is needed for Production I either need to resave the file as a Version 3 AI or an EPS.  I'm trying to do it within a Script but I'm not sure how to structure the IF/ELSE IF statements based on Radio Button.

Any Assistance would be appreciated!

 

var doc = app.activeDocument;
var choice;
var w = new Window("dialog");
w.text = "Production Art Save Options";
var mySelection = w.add("statictext");
mySelection.text = "Please Verify File Type Needed";
var g = w.add("group");
var a = g.add("radiobutton", undefined, "AI");
var b = g.add("radiobutton", undefined, "EPS");
var button = w.add("button", undefined, "OK");
var button2 = w.add("button", undefined, "Cancel");
var myMessage = w.add("statictext");
myMessage.text = "“Every Choice You Make Has An End Result” – Zig Ziglar";

var radiobuttons = [a, b];
for (var i = 0; i < radiobuttons.length; i++) {
    (function (i) {
        radiobuttons[i].onClick = function () {
            choice = radiobuttons[i].text;
        };
    })(i);
}
w.show();

////////////////////////////////
////////////////////////////////

if (choice == "AI") {

    // Saves file Format as a Version 3 AI 

} else if (choice !=="AI") {

    // Saves File Format as Current Version EPS
} 

//////////////////  SAVE LOCATION ///////////////////////////////////
/////////////////////////////////////////////////////////////////////

var strEnter = doc.name; //alert(strEnter);
var soNum = strEnter.slice(0,7);
var strEnter = (soNum); //alert(strEnter);
var sc = "/";	
var folderString = "C:" + sc + "Layout" + sc;


 // USED TO CREATE THE PRODUCTION FILE ONCE PROOF IS APPROVED
 var saveString = (folderString + strEnter); alert(saveString);
 newFile = new File (saveString);
 
 //Checking for overwrite
if (newFile.exists === true) {
if (confirm("This file already exists. Do you want to replace it?") === true) {
doc.saveAs(newFile);
     doc.close;
     }
 }
if (newFile.exists === false) {
var saveString = (folderString + strEnter); alert(saveString);
 newFile = new File (saveString);
         doc.saveAs(newFile);
doc.close;
 }
TOPICS
Scripting

Views

200

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jun 15, 2022 Jun 15, 2022

Here's what I got to work:

var strEnter = doc.name;
var soNum = strEnter.slice(0,7);
var strEnter = (soNum); //alert(strEnter);
var folderString = (folderPrefix + folder1); //alert(folderString);
var saveString = (folderString + strEnter + ".ai")
var saveString2 = (folderString + strEnter + ".eps");
var newFile = new File (saveString); 
var newFile2 = new File (saveString2);

//Create the folder structure if it does not exist
activeFolder = new Folder(folderString);
    if (activeFolder.exists ==
...

Votes

Translate

Translate
Adobe
Participant ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

hey @BryanPagenkopf 

 

check out my Example, replace the alert for your code to save Format you need

 

var w = new Window("dialog");
w.text = "Production Art Save Options";
var mySelection = w.add("statictext");
mySelection.text = "Please Verify File Type Needed";
var g = w.add("group");
var a = g.add("radiobutton", undefined, "AI");
a.onClick = SaveIlustratorFormat;
var b = g.add("radiobutton", undefined, "EPS");
b.onClick=SaveEPSFormat
var button2 = w.add("button", undefined, "Cancel");
var myMessage = w.add("statictext");
myMessage.text = "“Every Choice You Make Has An End Result” – Zig Ziglar";

function SaveIlustratorFormat(){
alert("AI Format")
w.close();

    }

function SaveEPSFormat(){
    alert("EPS Format")
    w.close();
    }
w.show();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

Have you tried turning your computer off and back on?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

LATEST

Here's what I got to work:

var strEnter = doc.name;
var soNum = strEnter.slice(0,7);
var strEnter = (soNum); //alert(strEnter);
var folderString = (folderPrefix + folder1); //alert(folderString);
var saveString = (folderString + strEnter + ".ai")
var saveString2 = (folderString + strEnter + ".eps");
var newFile = new File (saveString); 
var newFile2 = new File (saveString2);

//Create the folder structure if it does not exist
activeFolder = new Folder(folderString);
    if (activeFolder.exists === false) {
    activeFolder.create();
       }

if (choice2 === "AI"){
    var NamePreset = 'Illustrator 3';
    var saveOpts = new IllustratorSaveOptions()
    saveOpts.viewAfterSaving === false
    
    //Checking for overwrite
	if (newFile.exists === true) {
		if (confirm("Replace existing File?")) {
			doc.saveAs(newFile, saveOpts);
			doc.close;
		}
	} else {
		newFile = new File (saveString);
		doc.saveAs(newFile, saveOpts);
		doc.close;
	}
}else if (choice2 !== "AI"){
    var NamePreset = 'Illustrator 2020 EPS';
    var saveOpts = new EPSSaveOptions();
    saveOpts.viewAfterSaving === false
    
    //Checking for overwrite
	if (newFile2.exists === true) {
		if (confirm("Replace existing File?")) {
			doc.saveAs(newFile2, saveOpts);
			doc.close;
		}
	} else {
		newFile2 = new File (saveString2);
		doc.saveAs(newFile2, saveOpts);
		doc.close;
	}
}

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines