• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Please help with simple automation - add filename text below image

Community Beginner ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Would you kindly help me automate the following operations? I have to modify 547 images, and it'll take me 10-12 hours by hand. I'm embedding the image filename below the image for placement on a website.

FWIW, I'm an event photographer. I work almost exclusively in Lightroom Classic and DxO PhotoLab and have long since forgotten most of what I knew about Photoshop 20 years ago.

 

  1. Open 1800x1200px jpeg and place it at the top of an 1800x1300px canvas (with transparent background).
  2. Create text field, centered horizontally in the bottom 100px band, and paste image filename.
  3. Save with image filename as PSD and PNG.

 

janee_0-1678904500107.png

 

 

 

Any suggestions would be most welcome. Thanks! An example file is attached.

TOPICS
Actions and scripting

Views

5.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Contributor , Mar 15, 2023 Mar 15, 2023

I usually receive the spreadsheet from clients/interns but I've done it 2-3 times on my own using Excel/Google Spreadsheets and Windows Explorer. I know I did it once with full paths but if you want to shorten the path to just the filenames...

  1. Navigate to folder in Windows Explorer
  2. Select all files
  3. Hold SHIFT, Right Click and choose Copy as Path
  4. Paste into Excel
  5. Use Replace function to remove first part of path so you are left with just filenames
    Takes longer to type this than to actually do it 🙂

scr_Excel.png

Here

...

Votes

Translate

Translate
Community Expert , Mar 15, 2023 Mar 15, 2023

This new script will handle the batch processing and saving into PSD and PNG versions, it is self-contained, and there is no need to record actions for use with Automate/Batch or Image Processor Pro. You will be prompted to select an input folder and an output folder.

 

Note: All input files are expected to have a resolution of 300ppi (as per your sample) for the text size to be consistent/correct.

 

/*
Batch Add Filename to 1800x1200px Images & Save PSD & PNG.jsx
https://community.adobe.com/t5/
...

Votes

Translate

Translate
Community Expert , Jul 31, 2023 Jul 31, 2023
quote

I am just needing the script to output it as a jpg only (not psd or png)


By @Shoua5C98

 

Try this script, it should be close enough and can be easily tweaked if you need it "pixel perfect" to your samples. Let me know if there are any major issues that you can't figure out:

 

/*
Batch Add Filename to Lower Right of Canvas.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/please-help-with-simple-automation-add-filename-text-below-image/td-p/13652732
v1.0, 1st August 2023, Steph
...

Votes

Translate

Translate
Adobe
Community Beginner ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

Thank you. I really appreciate your time and expertise. I spent hours trying to figure it out to no avail. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

As all samples are normalised to 300ppi results should at least be consistent.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

I am just needing the script to output it as a jpg only (not psd or png)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

quote

I am just needing the script to output it as a jpg only (not psd or png)


By @Shoua5C98

 

Try this script, it should be close enough and can be easily tweaked if you need it "pixel perfect" to your samples. Let me know if there are any major issues that you can't figure out:

 

/*
Batch Add Filename to Lower Right of Canvas.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/please-help-with-simple-automation-add-filename-text-below-image/td-p/13652732
v1.0, 1st August 2023, Stephen Marsh
*/

#target photoshop

// Set the input and output folders
var inputFolder = Folder.selectDialog("Please select the input folder:");
var outputFolder = Folder.selectDialog("Please select the output folder:");

// Limit the input files, add or remove extensions as required
var fileList = inputFolder.getFiles(/\.(webp|tif|tiff|jpg|jpeg|psd|psb|png)$/i);
fileList.sort();

// Set the dialog and ruler options
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;

// Set the file processing counter
var fileCounter = 0;

// Process the input files
for (var i = 0; i < fileList.length; i++) {

    open(fileList[i]);

    //activeDocument.resizeImage(null, null, 300, ResampleMethod.NONE);
    var docName = activeDocument.name.replace(/\.[^\.]+$/, '');
    var textLayer = activeDocument.artLayers.add();
    textLayer.kind = LayerKind.TEXT;
    var theText = textLayer.textItem;
    var theColor = new SolidColor;
    theColor.rgb.red = 255;
    theColor.rgb.green = 255;
    theColor.rgb.blue = 255;
    textLayer.textItem.color = theColor;
    theText.position = [500, 500];
    theText.justification = Justification.RIGHT;
    //theText.font = 'Arial-Regular';
    theText.font = 'ArialMT';
    theText.size = 8;
    theText.contents = docName;
    alignToSel('AdRg');
    alignToSel('AdBt');
    activeDocument.activeLayer.translate(-25, -25);
    var saveJPEGName = File(outputFolder + "/" + docName + ".jpg");
    saveJPEG(saveJPEGName);
    activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    fileCounter++;
}

app.displayDialogs = savedDisplayDialogs;
app.preferences.rulerUnits = originalRulerUnits;

alert('Script completed!' + '\n' + fileCounter + ' files saved to:' + '\r' + outputFolder.fsName);


// FUNCTIONS //

function alignToSel(method) {
    /* https://gist.github.com/MarshySwamp/df372e342ac87854ffe08e79cbdbcbb5 */

    //www.ps-scripts.com/viewtopic.php?f=66&t=7036&p=35273&hilit=align+layer#p35273
    /* 
    //macscripter.net/viewtopic.php?id=38890
    AdLf = Align Left
    AdRg = Align Right
    AdCH = Align Centre Horizontal
    AdTp = Align Top
    AdBt = Align Bottom
    AdCV = Align Centre Vertical
    */

    app.activeDocument.selection.selectAll();

    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
    desc.putReference(charIDToTypeID("null"), ref);
    desc.putEnumerated(charIDToTypeID("Usng"), charIDToTypeID("ADSt"), charIDToTypeID(method));
    try {
        executeAction(charIDToTypeID("Algn"), desc, DialogModes.NO);
    } catch (e) { }

    app.activeDocument.selection.deselect();
}

function saveJPEG(saveFile) {
    var jpgOptns = new JPEGSaveOptions();
    jpgOptns.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgOptns.embedColorProfile = true;
    jpgOptns.matte = MatteType.NONE;
    jpgOptns.quality = 10;
    activeDocument.saveAs(saveFile, jpgOptns, true, Extension.LOWERCASE);
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 01, 2023 Aug 01, 2023

Copy link to clipboard

Copied

THIS IS EXACTLY WHAT I NEEDED!!! What a HUGE time saver!! Thank you so much!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2023 Aug 01, 2023

Copy link to clipboard

Copied

quote

THIS IS EXACTLY WHAT I NEEDED!!! What a HUGE time saver!! Thank you so much!!


By @Shoua5C98


You're welcome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2023 Aug 01, 2023

Copy link to clipboard

Copied

Nicely written, @Stephen Marsh !

 

Jane

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2024 Jun 11, 2024

Copy link to clipboard

Copied

Is it possible to change this script so it saves the file with a JPG extension instead of PSD ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2024 Jun 11, 2024

Copy link to clipboard

Copied

Making a comment- I am totally over-whelmed by scripting (Don't know anything!). But if you are using Lightroom-Classic, you can do this function (Save as JPG with FIlename, or other metadata) so easily with Lr-Classic.

-Select photos (as many as you want!) in the LrC library

-Use the Print Module to Design the 'page' with 'Photo Info' metadata.

- with the [Print Job] set to JPG Save all images to JPG.

2024-06-12 05_06_01-Roberts Catalog-v13-3 - Adobe Photoshop Lightroom Classic - Print.jpg

 

Regards. My System: Lightroom-Classic 14.0, Photoshop 26.0, ACR 17.0, Lightroom 8.0, Lr-iOS 9.0.1, Bridge 15.0.0, Windows-11.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 11, 2024 Jun 11, 2024

Copy link to clipboard

Copied

Lightroom can also output files with a watermark.

I use a Photoshop script at work to create stylized text but yes it would probably be a bit overwhelming for someone without coding knowledge.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2024 Jun 11, 2024

Copy link to clipboard

Copied

LATEST
quote

Is it possible to change this script so it saves the file with a JPG extension instead of PSD ?


By @Michael37981923jv7y


Which script, there are multiple scripts in this topic.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 16, 2023 Mar 16, 2023

Copy link to clipboard

Copied

Thanks for the suggestion, but wouldn't this just append the same single filename entered in step 5 to all 547 images? I want each image to have its own filename appended. In any case, I got it done with Variables, as noted above.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

quote

Thanks for the suggestion, but wouldn't this just append the same single filename entered in step 5 to all 547 images?

By @JacquesCornell

 

The message you replied to used ChatGPT and contained a spam link. It has been removed from the thread.

Jane

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines