Copy link to clipboard
Copied
I have a lot of .ai files with logo and I need to export them into PNG files. Is there an antomatic way of doing it? I know you cannot record the export part in Action...
Hi,
Yes this possible via script. I have simple script that exports all selected items of the active document as PNG, but this can be modified to run on all multiple documents.
My question, is do you want to export all items inside all documents or some specific? Coudl you share some ai sample files
Below is sample script
var doc = app.activeDocument;
var docAssets = doc.assets;
var assetIDArray = new Array();
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = '';
...
Hi,
You can use following snippet for your documents. When you run the script it will ask for the folder where source file exists. So select source_files folder in your case and png will be exported at the Desktop.
var _folder = Folder.selectDialog();
if (_folder != null) {
var _files = _folder.getFiles('*.ai');
for (var f = 0; f < _files.length; f++) {
var doc = app.open(_files[f]);
var docAssets = doc.assets;
var assetIDArray = new Array();
var itemToE
...
Copy link to clipboard
Copied
Hi,
Please see the thread below, if that helps you
Copy link to clipboard
Copied
that is what I'm doing for the moment. The painful things is to open up hundreds of .ai files one by one, export them as multiple assets, and close them one by one.
I think there is a way to speed it up by using scrips since I only need to open a file and export them to png, right?
Copy link to clipboard
Copied
Hi,
Yes this possible via script. I have simple script that exports all selected items of the active document as PNG, but this can be modified to run on all multiple documents.
My question, is do you want to export all items inside all documents or some specific? Coudl you share some ai sample files
Below is sample script
var doc = app.activeDocument;
var docAssets = doc.assets;
var assetIDArray = new Array();
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = '';
itemToExport.document = false;
var assetArray = new Array();
for (var i = 0; i < app.selection.length; i++) {
var asset = docAssets.add(app.selection[i]);
assetIDArray.push(asset.assetID);
}
itemToExport.assets = assetIDArray;
var options = new ExportForScreensOptionsPNG24();
app.activeDocument.exportForScreens(File('~/Desktop'), ExportForScreensType.SE_PNG24, options, itemToExport);
NOTE: This will export only selected items of the active document. if you answer above quetsion, we can help you in right direction.
Copy link to clipboard
Copied
Thank you soooo much!! it works on my mac!
To answer your question: I need to export all items inside all documents. it would be better if I can only give a path to all of the .ai and an automation could take process and output .pngs. if such automation works then these .pngs need to be put into different folders named by their source .ai files. It would be very hard to look up if all .pngs are saved in the same folder because their name is meaningless("Asset" + numbers).
I also upload a sample file here.
many thanks!
Copy link to clipboard
Copied
I just find out I cannot upload .ai as a attachment. I tried to change its suffix to other qualified format and none of them worked.
Copy link to clipboard
Copied
upload to google drive, dropbox, creative cloud or similar and post the link here
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi,
You can use following snippet for your documents. When you run the script it will ask for the folder where source file exists. So select source_files folder in your case and png will be exported at the Desktop.
var _folder = Folder.selectDialog();
if (_folder != null) {
var _files = _folder.getFiles('*.ai');
for (var f = 0; f < _files.length; f++) {
var doc = app.open(_files[f]);
var docAssets = doc.assets;
var assetIDArray = new Array();
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = '';
itemToExport.document = false;
var assetArray = new Array();
var _layer = doc.layers[0];
for (var i = 0; i < _layer.groupItems.length; i++) {
var asset = docAssets.add(doc.groupItems[i]);
assetIDArray.push(asset.assetID);
}
itemToExport.assets = assetIDArray;
var options = new ExportForScreensOptionsPNG24();
app.activeDocument.exportForScreens(File('~/Desktop'), ExportForScreensType.SE_PNG24, options, itemToExport);
}
}