Skip to main content
Waseem Dabbas
Known Participant
October 31, 2020
Question

How to write the name of the image file on the image itself?

  • October 31, 2020
  • 1 reply
  • 1002 views

I have let's say 100 images, and I want to write their names on them automatically, the purpose is to make a pdf catalogue of 3D product.

Hope someone can help.

 

This topic has been closed for replies.

1 reply

Stephen Marsh
Community Expert
Community Expert
October 31, 2020

There are many scripts for this task, here is one:

 

https://jkost.com/blog/2010/09/add-file-name-as-text-layer.html

AddFileName20pt.jsx 

 

If you can't script, you should be able to record the script into an action and add extra action steps to modify the text layer created by the script.

 

 

Waseem Dabbas
Known Participant
October 31, 2020

This is what I want, thank you very much.

Note for people who are trying to search the same methode, link provided doesn't work, so you can use this script:

 

 

 

// 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;
		
		// off set the text to be in the middle
		myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
		myTextRef.size = 20;
	}
	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!" );
}

save it with .jsx extension, for instance: Caption Name.jsx Place the script in your Photoshop /Presets/Scripts folder.

Launch Photoshop.
Open your image.
Select File > Scripts > Caption Name