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.
Any suggestions would be most welcome. Thanks! An example file is attached.
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...
Here
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/
...
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
...
Copy link to clipboard
Copied
I use Photoshop Variables for something like this. It has saved me a ton of time when creating sports cards, greeting cards, calendars, ads, and more.
https://helpx.adobe.com/photoshop/using/creating-data-driven-graphics.html
Copy link to clipboard
Copied
Thanks. I'm absorbing this tutorial. One question not answered there: How do I create a text variable data set comprising the filenames of all the images in a folder?
Copy link to clipboard
Copied
Also, how do I creat a pixel variable data set comprising all the images in a folder?
I've created a templace with a Background layer, a Filename text layer and an Image layer. Now I want PS to open the first image in the folder, paste it into the Image layer, then scrape the filename and paste it into the Filename layer, and save the result as a PSD.
Copy link to clipboard
Copied
Jeez, I sure wish we could edit our posts...
Copy link to clipboard
Copied
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...
Here is a video from Julieanne Kost of Adobe showing how to use Photoshop variables. Video is old but everything still works the same way.
https://www.youtube.com/watch?v=1PYu9dsaE5I
To edit your posts... click the More button at the bottom to choose Edit Reply
Copy link to clipboard
Copied
Thanks so much! I'll watch the video and give it a try.
Copy link to clipboard
Copied
The job is DONE! Thanks so much! The video was extremely helpful.
To batch rename the resulting files with the image names, I used an Automator action, provided by VikingOSX in the Apple Community forums.
https://discussions.apple.com/thread/252204380
It uses a .csv file that I was able to create by modifying the TSV file I'd created for Variables.
Copy link to clipboard
Copied
The second batch script that I offered would have correctly named the files, as well as automating everything else. Just saying. :]
Copy link to clipboard
Copied
I don't see any "More" button. Guess I don't have full privileges, even though I am logged in.
FWIW, using Numbers on macOS, one cannot paste multiple pathnames into a spreadsheed. The workaround I found was to past them into a TextEdit document, save that document, append ".txt" to its filename, then drop that document onto the Numbers' app's icon. Sheesh.
Copy link to clipboard
Copied
To edit your posts... click the More button at the bottom to choose Edit Reply
By @Graphikjules
@JacquesCornell wrote:
I don't see any "More" button. Guess I don't have full privileges, even though I am logged in.
Moderators and users who have a certain number of posts can edit their replies. New users cannot, as that was (unfortunately) being abused by spammers.
Jane
Copy link to clipboard
Copied
This is an old Script by Paul Riggott that adds the document name bottom right and saves psds.
So you may need to adapt it to your specific needs, but is should demonstrate the workability.
// by paul riggott;
processFiles();
function processFiles(){
//// AMEND TO SUIT///////////////////////////////////////////////////////////////////////////
var fontSize = 24; // Font Size
var fontName = "Helvetica";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inputFolder = Folder.selectDialog("Please select the folder with Files to process");
if(inputFolder == null) return;
outputFolder = Folder.selectDialog("Please select the output folder");
if(outputFolder == null) return;
var fileList = inputFolder.getFiles(/\.(jpg|psd)$/i);
app.displayDialogs = DialogModes.NO;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
for(var a =0 ; a<fileList.length;a++){
var file = fileList[a];
open(file);
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var textColor = new SolidColor();
textColor.rgb.hexValue = '000000';
var newTextLayer = activeDocument.artLayers.add();
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.kind = TextType.POINTTEXT
newTextLayer.textItem.color = textColor;
newTextLayer.textItem.font = fontName;
newTextLayer.textItem.size = fontSize;
newTextLayer.textItem.contents = Name;
align("AdBt");
align("AdRg");
activeDocument.activeLayer.translate (-5, -5)
var fileName =activeDocument.name.match(/(.*)\.[^\.]+$/)[1];
var saveFile = File(outputFolder + "/" +Name + ".psd");
SavePSD(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
preferences.rulerUnits = strtRulerUnits;
function align(method) {
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){}
activeDocument.selection.deselect();
};
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
}
}
Copy link to clipboard
Copied
For my poor brain, this might as well be written in Greek and encrypted. I'm a photographer, not a coder.
Copy link to clipboard
Copied
Thanks for the suggestion, though.
Copy link to clipboard
Copied
You don't need to understand a script. You just need to put it in your scripts folder and run it! Make a copy of a few of the images in a new folder and test it.
Jane
Copy link to clipboard
Copied
If it doesn't create a canvas bigger than the image and place the name in that empty space, horizontally centered, I can't use it. And, I've no more chance of figuring out how to modify the script than a spaniel does of opening a jam jar.
Copy link to clipboard
Copied
An example of the result I'm aiming for is attached to my first post.
Copy link to clipboard
Copied
If it doesn't create a canvas bigger than the image and place the name in that empty space, horizontally centered, I can't use it. And, I've no more chance of figuring out how to modify the script than a spaniel does of opening a jam jar.
By @JacquesCornell
I appreciate that you don't use Photoshop any more, so this may be expecting too much, however, my take on this was that the script would get you halfway there, and then you would use a batch action to automate the final steps over all images.
I'll take a look at automating this for you.
Copy link to clipboard
Copied
The following script will *mostly* do what you require, all you additionally need to do is:
A) Save and install it:
B) Record the execution of the script into an action with steps to save as PNG and PSD
C) Run the action via Automate > Batch, or better yet – Image Processor Pro which will handle file saving into both PSD and PNG in a single run
Note: All input files are expected to have a resolution of 300ppi (as per your sample) for the text size to be consistent/correct.
/*
Add filename to footer of 1800x1200px Image.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/please-help-with-simple-automation-add-filename-text-below-image/td-p/13652732
v1.2, 16th March 2023, Stephen Marsh
*/
#target photoshop
activeDocument.resizeImage(null, null, 300, ResampleMethod.NONE);
var origBGCol = app.backgroundColor;
var newBGCol = new SolidColor();
newBGCol.rgb.red = 255;
newBGCol.rgb.green = 255;
newBGCol.rgb.blue = 255;
app.backgroundColor = newBGCol;
canvasSize(true, 100);
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 = 0;
theColor.rgb.green = 51;
theColor.rgb.blue = 153;
textLayer.textItem.color = theColor;
theText.position = [500, 500];
theText.justification = Justification.CENTER;
theText.font = 'Futura-Medium';
theText.size = 24;
theText.contents = docName;
setRectSel(1200, 0, 1300, 1800);
alignToSel('AdCH');
alignToSel('AdCV');
activeDocument.selection.deselect();
app.backgroundColor = origBGCol;
// FUNCTIONS //
function canvasSize(relative, height) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
descriptor.putBoolean(s2t("relative"), relative);
descriptor.putUnitDouble(s2t("height"), s2t("pixelsUnit"), height);
descriptor.putEnumerated(s2t("vertical"), s2t("verticalLocation"), s2t("top"));
executeAction(s2t("canvasSize"), descriptor, DialogModes.NO);
}
function setRectSel(top, left, bottom, right) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty( s2t( "channel" ), s2t( "selection" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor2.putUnitDouble( s2t( "top" ), s2t( "pixelsUnit" ), top );
descriptor2.putUnitDouble( s2t( "left" ), s2t( "pixelsUnit" ), left );
descriptor2.putUnitDouble( s2t( "bottom" ), s2t( "pixelsUnit" ), bottom );
descriptor2.putUnitDouble( s2t( "right" ), s2t( "pixelsUnit" ), right );
descriptor.putObject( s2t( "to" ), s2t( "rectangle" ), descriptor2 );
executeAction( s2t( "set" ), descriptor, DialogModes.NO );
}
function alignToSel(method) {
//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
*/
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) {}
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
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/photoshop-ecosystem-discussions/please-help-with-simple-automation-add-filename-text-below-image/td-p/13652732
v1.1, 16th March 2023, Stephen Marsh
*/
#target photoshop
// Optionally run a specified action
//var actionName = "Molten Lead"; // Action to run, change as needed
//var actionSet = "Default Actions"; // Action set to run, change as needed
// 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();
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
// Set the file processing counter
var fileCounter = 0;
// Process the input files
for (var i = 0; i < fileList.length; i++) {
var doc = open(fileList[i]);
// Run the optional action
//app.doAction(actionName, actionSet);
activeDocument.resizeImage(null, null, 300, ResampleMethod.NONE);
var origBGCol = app.backgroundColor;
var newBGCol = new SolidColor();
newBGCol.rgb.red = 255;
newBGCol.rgb.green = 255;
newBGCol.rgb.blue = 255;
app.backgroundColor = newBGCol;
canvasSize(true, 100);
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 = 0;
theColor.rgb.green = 51;
theColor.rgb.blue = 153;
textLayer.textItem.color = theColor;
theText.position = [500, 500];
theText.justification = Justification.CENTER;
theText.font = 'Futura-Medium';
theText.size = 24;
theText.contents = docName;
setRectSel(1200, 0, 1300, 1800);
alignToSel('AdCH');
alignToSel('AdCV');
activeDocument.selection.deselect();
app.backgroundColor = origBGCol;
var savePSDName = File(outputFolder + "/" + docName + ".psd");
var savePNGName = File(outputFolder + "/" + docName + ".png");
savePSD(savePSDName);
exportPNG(savePNGName);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
fileCounter++;
}
app.displayDialogs = savedDisplayDialogs;
alert('Script completed!' + '\n' + fileCounter + ' files saved to:' + '\r' + outputFolder.fsName);
// FUNCTIONS //
function canvasSize(relative, height) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
descriptor.putBoolean(s2t("relative"), relative);
descriptor.putUnitDouble(s2t("height"), s2t("pixelsUnit"), height);
descriptor.putEnumerated(s2t("vertical"), s2t("verticalLocation"), s2t("top"));
executeAction(s2t("canvasSize"), descriptor, DialogModes.NO);
}
function setRectSel(top, left, bottom, right) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("channel"), s2t("selection"));
descriptor.putReference(s2t("null"), reference);
descriptor2.putUnitDouble(s2t("top"), s2t("pixelsUnit"), top);
descriptor2.putUnitDouble(s2t("left"), s2t("pixelsUnit"), left);
descriptor2.putUnitDouble(s2t("bottom"), s2t("pixelsUnit"), bottom);
descriptor2.putUnitDouble(s2t("right"), s2t("pixelsUnit"), right);
descriptor.putObject(s2t("to"), s2t("rectangle"), descriptor2);
executeAction(s2t("set"), descriptor, DialogModes.NO);
}
function alignToSel(method) {
//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
*/
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) {}
}
function savePSD(saveFile) {
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
psdSaveOptions.layers = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
}
function exportPNG(saveFile) {
var pngOptions = new ExportOptionsSaveForWeb();
pngOptions.PNG8 = false;
pngOptions.transparency = true;
pngOptions.interlaced = false;
pngOptions.quality = 100;
pngOptions.includeProfile = true;
pngOptions.format = SaveDocumentType.PNG;
activeDocument.exportDocument(File(saveFile), ExportType.SAVEFORWEB, pngOptions);
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
Many thanks to both of you gentlemen for your efforts. I opted, instead, for GraphikJules' Variables suggestion, as it seemed more comprehensible and modifiable, and it has worked.
Copy link to clipboard
Copied
I tried all the scripts listed here and none of them quite work for me. I am looking for a script that will give me the file name on the bottom without a white part being added, outputted as a jpg. My images are 300 dpi and usually sized to 5"x7", sometimes 8"x10". Is there a script for that?
Copy link to clipboard
Copied
As you have found, this is very much specific to the user and their workflow, it isn't generic.
Can you attach a layered PSD to clearly illustrate?
Copy link to clipboard
Copied
I have the layered PSD's but am unable to attach it here. I am getting an error message that .psd files are not supported, so I have uploaded on my CC: https://shared-assets.adobe.com/link/becb3605-b11a-4d77-6890-24f6bc74ab02
Copy link to clipboard
Copied
I have the layered PSD's but am unable to attach it here. I am getting an error message that .psd files are not supported, so I have uploaded on my CC: https://shared-assets.adobe.com/link/becb3605-b11a-4d77-6890-24f6bc74ab02
By @Shoua5C98
I'll take a look at this when I have some free time.