My items (text variable) are in a text file (List.txt). The text file and the JSX file must be in the same folder. Try this JSX script:
[CODE]#target photoshop // MAC Finder ou WINDOWS Explorer (double click)
app.bringToFront(); // Brings the application to the front
displayDialogs = DialogModes.NO; // Disables dialog boxes
// Selection of the folder to process
alert("your JSX and TXT files must be in the same folder");
var record="";
var psd_Options = new PhotoshopSaveOptions(); // [PhotoshopSaveOptions]
psd_Options.layers = true; // preserves layers
psd_Options.embedColorProfile = true; // preserves the color profile
psd_Options.annotations = true; // preserves annotations
psd_Options.alphaChannels = true; // preserves alpha channels
psd_Options.spotColors = true; // preserves inks
var mainFolder = File($.fileName).path; // The JSX and datas current folder
var inputFolder = Folder.selectDialog("Select the folder where your templates are : ");
var fileList = inputFolder.getFiles(/\.(psd|)$/i);
var outputFolder = Folder(inputFolder + "/save");
if (!outputFolder.exists) outputFolder.create();
var datas = File(mainFolder + "/List.txt");
var dataList = new Array();
datas.open('r');
var iD = 0;
while(!datas.eof)
{
record = datas.readln();
dataList[iD] = record;
iD++;
}
datas.close();
// If there is no template in the folder : end of process
if (fileList.length==0) {
alert("There is not any template in this folder.");
}
else {
main();
}
function main() {
var nbrTemplates = fileList.length;
var nbrItems = dataList.length
for (i=0;i<nbrTemplates;i++) {
var docRef = open(fileList[i]);
for (j=0;j<nbrItems;j++) {
docRef.activeLayer=docRef.layers[0];
docRef.layers[0].textItem.contents = dataList[j];
var docName = docRef.name;
var docName = docName.substring( 0, docName.indexOf('.'));
var saveFile = File(outputFolder + "/" + docName + "-" + j + 1 + ".psd");
docRef.saveAs(saveFile, psd_Options);
}
docRef.close(SaveOptions.DONOTSAVECHANGES);
}
}[/CODE]