Copy link to clipboard
Copied
Hello Community, I have 10,000+ individual ai files stored in folders. For the most part, there are 2-3 files in each folder. I need to save a png copy of each individual file, and keep them in the same folder as their respective ai file. I also would like to save the naming conventions of each file. Obviously, doing this manually would take a lifetime. I'm looking for a solution to achieve this overnight if possible. Any information or feedback on how I can manage this would be much appreciated. Thanks in advance!
Hi,
You can try following script
function main() {
var folder = Folder.selectDialog('Select folder.', '~');
if (folder) {
if (folder) {
var _files = folder.getFiles('*.ai');
for (var i = 0; i < _files.length; i++) {
doc = app.open(File(_files[i]));
doc.activate();
try {
doc.exportFile(new File(folder + '/' + doc.name.split('.')[0] + '.png'), ExportType.PNG24, new ExportOptionsPNG24());
...
For specifing the resolution you need to use the imageCapture method. Below is the another version of the script, change value of the resolution as required.
function main() {
var folder = Folder.selectDialog('Select folder.', '~');
if (folder) {
if (folder) {
var _files = folder.getFiles('*.ai');
for (var i = 0; i < _files.length; i++) {
doc = app.open(File(_files[i]));
doc.activate();
var resolution = 200;
...
Copy link to clipboard
Copied
I would probably try a batch action in Photoshop. Open Photoshop, open the Actions panel, then create a new action. This will start recoring. Open a file and specify the resolution for rendering, then save as PNG. Now use Photoshop’s Batch actions (File > Automate > Batch) to convert the files. I think you will need to do one folder at a time.
Copy link to clipboard
Copied
Hi,
You can try following script
function main() {
var folder = Folder.selectDialog('Select folder.', '~');
if (folder) {
if (folder) {
var _files = folder.getFiles('*.ai');
for (var i = 0; i < _files.length; i++) {
doc = app.open(File(_files[i]));
doc.activate();
try {
doc.exportFile(new File(folder + '/' + doc.name.split('.')[0] + '.png'), ExportType.PNG24, new ExportOptionsPNG24());
}
catch (e) {
alert('Export of file "' + doc.name + '" failed.\n' + e.message);
return;
} finally {
doc.close(SaveOptions.DONOTSAVECHANGES);
}
}
alert('Success!\nPNGs saved to ' + folder);
}
}
}
main();
You can choose folder where ai files exists and script will save the document as png in the same folder.
NOTE: As you said there are many folders, currently you need to run this script for all folders each time. But if there is any structure of your folder like folders and subfolders then script can be modified so that it will run for all files for all folders all together.
Copy link to clipboard
Copied
This is awesome! This is exactly what I was looking for. One quick follow-up question.. How can I adjust the settings so that it saves the png at the highest resolution?
Copy link to clipboard
Copied
For specifing the resolution you need to use the imageCapture method. Below is the another version of the script, change value of the resolution as required.
function main() {
var folder = Folder.selectDialog('Select folder.', '~');
if (folder) {
if (folder) {
var _files = folder.getFiles('*.ai');
for (var i = 0; i < _files.length; i++) {
doc = app.open(File(_files[i]));
doc.activate();
var resolution = 200;
var opts = new ImageCaptureOptions();
opts.resolution = resolution;
opts.antiAliasing = true;
opts.transparency = true;
try {
var pngFile = new File(folder + '/' + doc.name.split('.')[0] + '.png');
doc.imageCapture(pngFile, doc.geometricBounds, opts);
}
catch (e) {
alert('Export of file "' + doc.name + '" failed.\n' + e.message);
return;
} finally {
doc.close(SaveOptions.DONOTSAVECHANGES);
}
}
alert('Success!\nPNGs saved to ' + folder);
}
}
}
main();
Copy link to clipboard
Copied
Thank you so much!!!!!! You are awesome
Copy link to clipboard
Copied
Hgffjf