Can anyone help me write a script for illustrator CC2017 that Export files to web (legacy) as JPG then save the file and close after. I have 700 files each with 2 art boards and it would be painful to click file>Export>Save For Web(legacy) then right the file name and save the file then close.
Here is the script as per your requirement. I have just updated Script 1 to match your requirement. By default it assumes ruler is in Points and convert it into inches and use in the file name. You can add more check to handle other ruler units. This will have a-z if artboards are not more than 26 in case artboards are more than 26, it will show something else. Using ASCII code for this
var folder = Folder.selectDialog();
if (folder) {
var files = folder.getFiles("*.ai");
for (var i = 0; i < files.length; i++) {
var currentFile = files[i];
app.open(currentFile);
var activeDocument = app.activeDocument;
var jpegFolder = Folder(currentFile.path + "/JPG");
if (!jpegFolder.exists)
jpegFolder.create();
var codeStart = 97; // for a;
for (var j = 0; j < activeDocument.artboards.length; j++) {
var activeArtboard = activeDocument.artboards[j];
activeDocument.artboards.setActiveArtboardIndex(j);
var bounds = activeArtboard.artboardRect;
var left = bounds[0];
var top = bounds[1];
var right = bounds[2];
var bottom = bounds[3];
var width = right - left;
var height = top - bottom;
if (app.activeDocument.rulerUnits == RulerUnits.Points) { //Add more if for more conversions
width = width / 72;
height = height / 72;
}
var fileName = activeDocument.name.split('.')[0] + "-" + String.fromCharCode(codeStart) + "-" + width + "x" + height + ".jpg";
var destinationFile = File(jpegFolder + "/" + fileName);
var type = ExportType.JPEG;
var options = new ExportOptionsJPEG();
options.antiAliasing = true;
options.artBoardClipping = true;
options.optimization = true;
options.qualitySetting = 100; // Set Quality Setting
activeDocument.exportFile(destinationFile, type, options);
codeStart++;
}
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
currentFile = null;
}
}