If you're looking to convert all ai files in a specific folder into jpg format, the following javascript code will help you achieve that. This code prompts you to choose a folder containing 700 files.
Script 1: Using JPEGQuality
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();
for (var j = 0; j < activeDocument.artboards.length; j++) {
var activeArtboard = activeDocument.artboards[0];
activeDocument.artboards.setActiveArtboardIndex(j);
var fileName = activeDocument.name.split('.')[0] + "Artboard" + (j + 1) + ".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);
}
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
currentFile = null;
}
}
Each ai file contains two artboards, resulting in two jpg files per file. You have the flexibility to customize file names and output folder locations according to your needs.
Script 2: By changing resolution
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 fileName = activeDocument.name.split('.')[0] + ".jpg";
var destinationFile = File(jpegFolder + "/" + fileName);
// Export Artboard where you can set resolution for an image. Set to 600 by default in code.
var opts = new ImageCaptureOptions();
opts.resolution = 600;
opts.antiAliasing = true;
opts.transparency = true;
try {
activeDocument.imageCapture(new File(destinationFile), activeDocument.geometricBounds, opts);
} catch (e) {
}
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
currentFile = null;
}
}
Script 2 generates only one jpg file per ai file, disregarding the artboards. Feel free to utilize both scripts to streamline your tasks.