Copy link to clipboard
Copied
Hi,
I have only one artboard on which some data is modified with a set of variables.
I would like to create an action that allows you to export it to png using different names for each row of the set.
Of course I use the actions panel, but exporting to a specific folder the system uses the same name as the output file, effectively replacing the file just created. So instead of having 30 different pngs, I only have 1 (the last one of the set).
Can anyone help me?
Copy link to clipboard
Copied
Hi,
I have only one artboard on which some data is modified with a set of variables.
I would like to create an action that allows you to export it to png using different names for each row of the set.Of course I use the actions panel, but exporting to a specific folder the system uses the same name as the output file, effectively replacing the file just created. So instead of having 30 different pngs, I only have 1 (the last one of the set).
Can anyone help me?
By @Andrea38138254hjmgTellCulver
Certainly! To create multiple PNG files with different names for each row of the set, you need to create an action in Adobe Illustrator, but also use a bit of automation to avoid overwriting files. Since Illustrator’s actions don’t directly support loops or variable-specific file naming, you will need to make use of Illustrator’s Variables panel and scripting (JavaScript).
Prepare the Variables:
Setup your Action (Manual Steps for Exporting):
Using Variables for Dynamic Export Names: Illustrator’s Actions panel doesn't support automatic naming of files based on the variable data. You need to either modify the file name before exporting it for each variable or use a script.
Write a Script to Automate Exporting (with Variable-based Names): Here’s a simple JavaScript that you can run in Illustrator to export the artboard as PNGs with different filenames based on your variable data.
#target illustrator
// Set up your folder and file names
var doc = app.activeDocument; // Get the active document
var exportFolder = Folder.selectDialog("Select the folder to save PNGs"); // Choose export folder
// Check if a folder is selected
if (exportFolder != null) {
var csvFile = File.openDialog("Select your CSV file", "*.csv"); // Choose CSV with variable data
// Open the CSV file
if (csvFile != null) {
csvFile.open('r');
var rows = [];
// Read the CSV content into an array (assuming the CSV has one value per row)
while (!csvFile.eof) {
var row = csvFile.readln().split(','); // Split by commas, assuming CSV format
rows.push(row);
}
csvFile.close();
// Loop through each row in the CSV
for (var i = 0; i < rows.length; i++) {
var rowData = rows[i][0]; // Assuming each row has a single column (adjust if your CSV is structured differently)
// Apply the variable data to the artboard (this assumes you are using text variables in your document)
doc.textFrames.getByName("TextPlaceholder").contents = rowData; // Replace with your text placeholder name
// Export the file as PNG
var exportOptions = new ExportOptionsPNG24();
exportOptions.artBoardClipping = true;
exportOptions.antiAliasing = true;
exportOptions.transparency = true;
// Construct the file name based on the data (e.g., Row_1.png, Row_2.png)
var fileName = "Exported_" + rowData + ".png";
var exportFile = new File(exportFolder.fsName + "/" + fileName);
doc.exportFile(exportFile, ExportType.PNG24, exportOptions);
}
alert("Export complete!");
}
}
​
Running the Script:
Benefits of this Approach: