Copy link to clipboard
Copied
In the old forum there was a very useful script to import words from a text file into individual layers in Photoshop. These old posts are gone unfortunately and due to a hard drive failure and lack of proper backup, I have lost the script. It was in forums.adobe.com/thread/2200206 and here is a portion of the post I found in a cache. Does anyone have the complete script?
Here's a quick script that can do. It assumes that there is a text file on your desktop named "name list.txt" it also assumes that the text using a return between names file, this can be changed to commas or anything else you want to use. You must also have an open file to make it work. It does not define the font or the font size, but you can put in the script or select all layers later and change it at once.
#target photoshop var doc = activeDocument var textFile = new File(Folder.desktop+ '/name list.txt'); var list = readText (textFile).split('\n'); for (var i = 0;i<list.length;i++){ var="" artlayerref="doc.artLayers.add()" artlayerref.kind="LayerKind.TEXT;" textitemref="artLayerRef.textItem;" textitemref.contents="list[i]" }="" function="" readtext(file){="" if="" (textfile.exists)="" {="" textfile.encoding="UTF8" ;="" textfile.linefeed="unix" textfile.open("r",="" "text",="" "????");="" str="textFile.read();" textfile.close();="" return="" str;="" <="" pre=""> </list.length;i++){>
Copy link to clipboard
Copied
In the old forum there was a very useful script to import words from a text file into individual layers in Photoshop. These old posts are gone unfortunately and due to a hard drive failure and lack of proper backup, I have lost the script. It was in forums.adobe.com/thread/2200206 and here is a portion of the post I found in a cache. Does anyone have the complete script?
Here's a quick script that can do. It assumes that there is a text file on your desktop named "name list.txt" it also assumes that the text using a return between names file, this can be changed to commas or anything else you want to use. You must also have an open file to make it work. It does not define the font or the font size, but you can put in the script or select all layers later and change it at once.
#target photoshop var doc = activeDocument var textFile = new File(Folder.desktop+ '/name list.txt'); var list = readText (textFile).split('\n'); for (var i = 0;i<list.length;i++){ var="" artlayerref="doc.artLayers.add()" artlayerref.kind="LayerKind.TEXT;" textitemref="artLayerRef.textItem;" textitemref.contents="list[i]" }="" function="" readtext(file){="" if="" (textfile.exists)="" {="" textfile.encoding="UTF8" ;="" textfile.linefeed="unix" textfile.open("r",="" "text",="" "????");="" str="textFile.read();" textfile.close();="" return="" str;="" <="" pre=""> </list.length;i++){>
Copy link to clipboard
Copied
This is not the same script, but perhaps similar enough?
Courtesy of Lumigraphics:
#target photoshop
addText();
function addText(){
if(documents.length > 0){
var originalDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.ERROR;
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
try{
var testFile = new File('~/Desktop').openDlg('Select import file', '*.txt'); //select text file
if(testFile != null){ //catch user cancel
testFile.open('r');
var textLine = testFile.readln();
var docRef = activeDocument;
var LayerRef = null;
var TextRef = null;
var pos = 200;
while(textLine != ''){ //read in text one line at a time
LayerRef = docRef.artLayers.add();
LayerRef.kind = LayerKind.TEXT; //new text layer
TextRef = LayerRef.textItem;
TextRef.contents = textLine; //text from file
//optional text styling, customize to suit
pos = pos + 50;
TextRef.position = new Array(pos, pos);
preferences.rulerUnits = Units.POINTS;
TextRef.size = 48;
TextRef.useAutoLeading = false;
TextRef.leading = 48;
TextRef.font = 'Calibri-Bold';
TextRef.justification = Justification.CENTER;
TextRef.autoKerning = AutoKernType.METRICS;
//end optional text styling
textLine = testFile.readln(); //read the next line from file
}
testFile.close();
}
}
catch(e){
alert(e + e.line);
preferences.rulerUnits = originalRulerUnits;
app.displayDialogs = originalDialogMode;
return;
}
preferences.rulerUnits = originalRulerUnits;
app.displayDialogs = originalDialogMode;
}
else{
alert('You must have a document open to run this script.');
return;
}
return;
}
Copy link to clipboard
Copied
Thank you very much. I will give it a whirl.