Skip to main content
Participant
January 29, 2020
Question

How to Write "Save As" Script

  • January 29, 2020
  • 2 replies
  • 6531 views

I am fairly new to Illustrator (less than 6 months) but I have managed to teach my self the basics to do what I need to do. I complete checking and minor editing of about 100 illustrator files a week for a client of mine, each of which needs to be saved in 5 differnt formats. Currently I am using the commands SAVE, SAVE AS, and SAVE FOR WEB (x3) to save the files in the original folder and to overwrite the existing file in there (all formats already exist in the original folder). I have done some research and belive that this process could be done automatically using a script. I have also tried to understand the coding language but it honestly goes right over my head. Can any one provide any assistance as to how I could write a script to do all the saving or possible point me in the direction of a simialr script that could be modified to suit my needs? Thanks in advance for any help.

This topic has been closed for replies.

2 replies

Ten A
Community Expert
Community Expert
January 30, 2020

You can find the latest references in adobe.io. However, exportForScreens not documented.

If you can use ESTK, You can refer Object Model Viewer. However, the first arg is a Folder object.

schroef
Inspiring
May 25, 2021

Where can i find this ESTK, this is old right?

schroef
Inspiring
May 25, 2021

I foudn it here, i already had i seemed. i was using estk for search, that didnt work

 

https://github.com/Adobe-CEP/CEP-Resources

 

I do wonder now i can get more info to show as your screenshot does. I see you have illustrator 24, mine shows 25

 

EDIT

i found it, its a bit in riddle form as usual. Still dont see the how we can set real width and height as the export for screen dialog shows.

Ten A
Community Expert
Community Expert
January 29, 2020

There are some snippets you can use...

 

//save as
var f = New File("-/Desktop/saveAsFileName.ai");
app.activeDocument.saveAs(f);

//save for web
var doc = app.documents[0];
var assets = doc.assets; 
var expOptions = new ExportForScreensItemToExport();
expOptions.artboards = 'all';
expOptions.document = true;
var jpegParam = new ExportForScreensOptionsJPEG();
jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;
jpegParam.antiAliasing = AntiAliasingMethod.None;
jpegParam.embedICCProfile = true;
jpegParam.scaleType = ExportForScreensScaleType.SCALEBYFACTOR;
jpegParam.scaleTypeValue = 3;
var fdr=new Folder("~/Desktop/exportFolder/");
doc.exportForScreens(fdr, ExportForScreensType.SE_JPEG80,  jpegParam, expOptions, "JPEG80_");

 

 

schroef
Inspiring
January 29, 2020

@Ten A

 

can i ask where you got these references from. Ive been searching for this for hours. This is not in their own official documentation. The latest scripting guides are from cc 2017 and basically have dinosaur code in them 😞