Copy link to clipboard
Copied
I have a script to add the file number to the front of the image for proofing. I would like to remove the first 4 characters in the 8 character file name in the script.
I don't code so I'm looking for the lines of code to add to the script.
It would help reduce paperwork errors when we show portraits.
Thanks for any help,
Fjuds
// this script is a variation of the script addTimeStamp.js that is installed with PH7
if ( documents.length > 0 )
{
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;
// off set the text to be in the bottom center
myTextRef.position = new Array( docRef.width / 3, docRef.height / 1.03 );
myTextRef.size = 60;
}
catch( e )
{
// An error occurred. Restore ruler units, then propagate the error back
// to the user
preferences.rulerUnits = originalRulerUnits;
throw e;
}
// Everything went Ok. Restore ruler units
preferences.rulerUnits = originalRulerUnits;
}
else
{
alert( "You must have a document open to add the filename!" );
}
You can put this line after line 23:
var shortName = fileNameNoExtension.substr (4)
Copy link to clipboard
Copied
This doesn't look like JavaScript for Adobe Acrobat.
Copy link to clipboard
Copied
Sorry, First time trying a form and posted to the wrong group. Its a Photoshop script.
Copy link to clipboard
Copied
[Question moved to Photoshop Scripting]
Copy link to clipboard
Copied
You can put this line after line 23:
var shortName = fileNameNoExtension.substr (4)