Help with add file name problem with Photoshop CS4

HL
Posted By
Howard_Lower
Oct 24, 2008
Views
385
Replies
1
Status
Closed
Frustrating problem: Help with add file name problem with Photoshop CS4. What happens is this. When I am in PS CS4 or CS3 and run the following script it runs fine. When I am in Bridge and go to tools/photoshop/batch and run the same script it runs until it wants interaction with preference.rulerunits. How do I get it to quit doing this so I can run in batch mode? Any help is appreciated. HLower

Script follows:

// this script is another variation of the script addTimeStamp.js that is installed with PS7

//Check if a document is open
if ( documents.length > 0 )
{
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.INCHES;

try
{
var docRef = activeDocument;

// Create a text layer at the front

var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;

//Set your parameters below this line

//If you wish to show the file extension, change the n to y in the line below, if not use n. var ShowExtension = "n";
// Insert any text to appear before the filename, such as your name and copyright info between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in). var TextBefore = "Lower© ";

// Insert any text to appear after the filename between the quotes. //If you do not want extra text, delete between the quotes (but leave the quotes in). var TextAfter = " ";

// Set font size in Points
myTextRef.size = 10;

//Set font – use GetFontName.jsx to get exact name
myTextRef.font = "Arial";

//Set text colour in RGB values
var newColor = new SolidColor();
newColor.rgb.red = 0;
newColor.rgb.green = 0;
newColor.rgb.blue = 0;
myTextRef.color = newColor;

// Set the position of the text – percentages from left first, then from top. myTextRef.position = new Array( 10, 99);

// Set the Blend Mode of the Text Layer. The name must be in CAPITALS – ie change NORMAL to DIFFERENCE.
myLayerRef.blendMode = BlendMode.NORMAL;

// select opacity in percentage
myLayerRef.opacity = 100;

// The following code strips the extension and writes tha text layer. fname = file name only

di=(docRef.name).indexOf(".");
fname = (docRef.name).substr(0, di);
//use extension if set
if ( ShowExtension == "y" )
{
fname = docRef.name
}

myTextRef.contents = TextBefore + " " + fname + " " + TextAfter;

}
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!" ); }

How to Improve Photoshop Performance

Learn how to optimize Photoshop for maximum speed, troubleshoot common issues, and keep your projects organized so that you can work faster than ever before!

DM
dave_milbut
Oct 24, 2008
you might want to try the scripting forum howard:

<http://www.adobeforums.com/webx?13@@.ef7f2cb>

Master Retouching Hair

Learn how to rescue details, remove flyaways, add volume, and enhance the definition of hair in any photo. We break down every tool and technique in Photoshop to get picture-perfect hair, every time.

Related Discussion Topics

Nice and short text about related topics in discussion sections