i´m new in using java script with photoshop and need some help.



I´ve already modyfied a script that creates a new text layer with the filename but now i neet to delete the first word.
For excample: "Cruise Tom" => "Tom"
I´m shure for you guys it´s quiet easy...
If someone could tell me where to insert which lines of code i would be verry thankful!!!
Bardioch
Code: Select all
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 = "Dateiname";
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;
// off set the text to be in the middle
myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
myTextRef.size = 40;
myTextRef.font = "Berlin Sans FB Demi";
myTextRef.justification = Justification.CENTER;
var newColor = new SolidColor();
newColor.rgb.red = 80;
newColor.rgb.green = 42;
newColor.rgb.blue = 14;
myTextRef.color = newColor;
}
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!" );
}