I have a PSD file called "WEB-MUG-12345" - I am able to use a script to put that name into that same PSD file and use actions to change font, size, placement.
I need to insert asterisks so in my PSD file it will read "*WEB-MUG-12345*". I am not able to insert asterisks like I usually edit text in Photoshop. I cannot have a jpeg layer of asterisks because I need to change the font to a barcode font, and this barcode must be scanned so the asterisks must be as proper text with the "WEB-MUG-12345".
When I used actions to manually insert asterisks, it saved the "12345" whereas I will need to do an automated batch sequence so this number will change with each new file.
This is the script I am currently using.
Many thanks in advance!
// this script is a variation of the script addTimeStamp.js that is installed with PH7
if ( documents.length > 0 )
{
var originalDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.ERROR;
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
try
{
var docRef = activeDocument;
// Now create a text layer at the front
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;
// strip the extension off
var fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split( "." );
if ( fileNameNoExtension.length > 1 ) {
fileNameNoExtension.length--;
}
fileNameNoExtension = fileNameNoExtension.join(".");
myTextRef.contents = fileNameNoExtension;
// Set the position of the text percentages from left first, then from top
myTextRef.position = new Array( docRef.width / 2.5, docRef.height / 3.5 );
myTextRef.size = 15.76;
}
catch( e )
{
// An error occurred. Restore ruler units, then propagate the error back
// to the user
preferences.rulerUnits = originalRulerUnits;
app.displayDialogs = originalDialogMode;
throw e;
}
// Everything went Ok. Restore ruler units
preferences.rulerUnits = originalRulerUnits;
app.displayDialogs = originalDialogMode;
}
else
{
alert( "You must have a document open to add the filename!" );
}
Courtesy of Add File Name as Text Layer « Julieanne Kost's Blog