Here is a script that will export all the files of the selected folder to PNG. You can specify the resolution in this code, and the image quality will be good. In this code, the default resolution is 600
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 pngFolder = Folder(currentFile.path + "/PNG"); if (!pngFolder.exists) pngFolder.create(); var fileName = activeDocument.name.split('.')[0] + ".png"; var destinationFile = File(pngFolder + "/" + 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; } }
If you want to export in jpg format, just change the file extension in the code in the next line
var fileName = activeDocument.name.split('.')[0] + ".png";
change to
var fileName = activeDocument.name.split('.')[0] + ".jpg";
In addition, you can change the file name and where the exported file will be saved as per your requirement.
Hope my answer helps you.
source share