Skip to main content
Participating Frequently
February 24, 2021
Question

Photoshop actions

  • February 24, 2021
  • 2 replies
  • 668 views

Hi
Sorry for the language, but I use an online translator.
I would like to make a script or action to automatically insert the file name as a caption in the lower part of an image in a polaroid-like white space (I have to take several thousand photos of various sizes)
Mario

 

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
February 26, 2021

This is not possible via actions, you need a script. You can record the run of the script into an action and then have an automation using both scripting and actions.

 

 

// https://forums.adobe.com/thread/2349403
// https://forums.adobe.com/message/11179771#11179771

#target photoshop
 
testText();
 
function testText(){
    if(documents.length > 0){
        var originalDialogMode = app.displayDialogs;
        app.displayDialogs = DialogModes.ERROR;
        var originalRulerUnits = preferences.rulerUnits; //save previous ruler units
        preferences.rulerUnits = Units.PIXELS;
        try{
            var docRef = activeDocument;
            var LayerRef = docRef.artLayers.add(); //add a text layer
            LayerRef.kind = LayerKind.TEXT;
            var TextRef = LayerRef.textItem;
            var fileNameNoExtension = docRef.name;
            fileNameNoExtension = fileNameNoExtension.split('.');
            if(fileNameNoExtension.length > 1){ //remove file extension
                fileNameNoExtension.length--;
                }
            fileNameNoExtension = fileNameNoExtension.join('.');
            TextRef.contents = fileNameNoExtension;
            TextRef.position = new Array(80, 120); //location in pixels
            preferences.rulerUnits = Units.POINTS;
            TextRef.size = 96; //text formatting
            TextRef.useAutoLeading = false;
            TextRef.leading = 42;
            TextRef.font = 'Calibri-Bold';
            }
        catch(e){
            preferences.rulerUnits = originalRulerUnits;
            app.displayDialogs = originalDialogMode;
            return;
            }
        preferences.rulerUnits = originalRulerUnits;
        app.displayDialogs = originalDialogMode;
        }
    else{
        alert('You must have a document open to run this script.');
        return;
        }
    }

 

 

The script may need modification if being used for batch processing.

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

Participating Frequently
February 27, 2021

Thank you very much for the reply, but with I am absolutely unable to handle a script. I was hoping it would be a simpler procedure.

Stephen Marsh
Community Expert
Community Expert
February 27, 2021

If you are unable to handle a script you have two choices:

 

1) Learn how to, I provided that info in the first link and you can search the web for many other sources of info and you should be able to find simple instructions in your native language on how to copy script code, save it and install or run the saved script file. You are not being asked to learn scripting, all you are doing is using a previously written script. You likely use scripts all the time in Photoshop without being aware of it as you don't need to save or install the scripts that ship with Photoshop.

 

2) Don't use Photoshop for this task and find other software that can do this task as a native feature. One such program is IrfanView.

 

Photoshop actions can't directly add the filename as a text layer. A script can do so. You can record the script into your batch action. The script will add the text and then the action can manipulate the text layer and perform other processing.

 

Participating Frequently
February 25, 2021

Thank you for your answer Lumigraphics, but I don't have the technical background to use your answer.

Legend
February 25, 2021

You could probably hire someone to write the script for you.