Copy link to clipboard
Copied
I have a test script I wrote to open illustrator files, add some text and then save them.
What I want to do is get a list of filenames, text info, and filename to save to, from a CSV. My example code works I just don't know how to import the CSV into the const filenames, const templatefiles, const personalisation etc
Thanks for any insight you guys can give 🙂
#target Illustrator
const filenames = ["f1", "f2","f3"]
const templatefiles = ["TEMPLATE_CUS_PAD40_03.ai", "TEMPLATE_CUS_PAD40_03.ai","TEMPLATE_CUS_PAD40_03.ai"];
const personalistation = ["personalisation text 1", "personalisation BLAH 2","personalisation MEH 3"];
const filepath = 'E:/Products/ALL FILES/';
function ProcessFiles()
{
for(processedfiles = 0; processedfiles < 3; processedfiles++){
File = app.open(new File(filepath + templatefiles[processedfiles]));
var doc = app.activeDocument;
var text = app.activeDocument.layers[0].textFrames.pointText([0, 0]);
app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
text.textRange.characterAttributes.size = 14.5;
text.textRange.characterAttributes.textFont = app.textFonts["SegoeScript-Bold"];
text.contents = personalistation[processedfiles];
text.position = [0,75];
var fname = filenames[processedfiles];
doc.saveAs(new File("E:/Products/scriptoutput/" + fname));
};
};
ProcessFiles();
Copy link to clipboard
Copied
You can use a CSV parser. In the past I used one such snippet I found at the following blog and it worked for my purpose
Open your CSV file and read it line by line in your JS and then pass each line of data to the method mentioned in the blog and you should recieve the list of values in an array.
You can search other parsers as well.
P.S.:- Be warned that looking at samples of modern JS won't work in extendscript for obvious reasons
-Manan