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

Help with Photoshop action, script, or variable not sure

Community Beginner ,
Oct 08, 2021 Oct 08, 2021

Copy link to clipboard

Copied

I have a lot of images that I need to add dates too. 4 images get the same date and are in the same folder. There are videos in that folder too.  Attatched images is an example of what I am trying to achieve. 

 

I'd like to be able to select every jpg in a folder add the date to it and save it back to the folder with " date" appended to the end. 

 

I tried this with actions and batch to select the folder but I'm unsure how to quickly change the date for each folder so I don't have to record the text date each time. 

 

I tried this with photoshop variables but I get stuck because I have to use the title of each file and that's just as time consuming as manually adding the date. This would be a great solution if I could tell it to grab every jpg in the folder when using it instead of naming each individaul file. 

I've not familiar enough with scripts to have tried them. 

TOPICS
Actions and scripting

Views

4.2K

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
Adobe
Community Expert ,
Oct 08, 2021 Oct 08, 2021

Copy link to clipboard

Copied

A script can Process all jpeg files in a folder.  A script can rename files.  What date do want to add to add to the  Jpeg files image name? Today's Date. Your birth date? If its a constant date like today's date the files can just be renamed they do not even need to be opened. If you need to have duplicate file in the folder with the two file names the script can copy the jpeg file?  There is no need to encode a new jpeg generation and lose some image quality. You should learn about scripting photoshop.   You can use Photoshop Batch to add a date to an image file name also Image Processor Pro can add a Date however they would open the original  jpeg and saves as additional copy with the dated names. You would beed toe select all the jpeg files ins the bridge and uset the  bridge menu Tools>Photoshop>Batch... or Image Pocessor Pro...

Capture.jpg

JJMack

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 ,
Oct 08, 2021 Oct 08, 2021

Copy link to clipboard

Copied

Thanks for the response I was really hoping you would help with this. I've read several of your feeback in the past!

 

I think maybe I didn't explain it well. I'm looking for a date that might not be associated with the file so i would specify what I want put on it. This is why I thought variables might work well but I got stuck with having to name every file instead of just selecting each file in the folder.

 

It almost worked with variables but i'd like to grab every jpg in a folder add a specfic text to that image, rename it with the word "date" appended to each name so I know that is the one that has been dated. So it would looks something like this. 

 

[Folder for show]  Folder contains 4 images that need the text put on it and then saved next to that one with the word "date" on the file.  So my file would be "Feature Story" and "Feature Story Date" 

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 ,
Oct 08, 2021 Oct 08, 2021

Copy link to clipboard

Copied

A Script can rename a file anyway you want as well as it can save a file with any file name you want. You would need to pass the parameters you want the script to use.  This is normally done using a ScriptUI Dialog.  You would be able to set the folder to process in the dialog or have a select folder button  in its the dialog you can use select the folder to process. You cans also set the Image file type or types you want to process in the folder.  You can  set Date suffix you you  added to the file names then click the dialog's run button.  The thing is you most likely do not know how to script Photoshop. That is why I suggested the image processor pro plug-in script you can download and install it from the web.   However,  its dialog does not have a way to filter the image files types to process. I will process all Image files in  a selected folder.  However, it can be used from the bridge where you would select just the Jpeg files you want to process in the Bridge's UI and then you would use Bridge's menu Tools >Photoshop>Image Processor Pro...  Photoshop will open and Photoshop will open Image Processor Pro's Dialog where you will set Image Processor Pro dialog to process the files selected in the Bridge  and have it save  Jpeg files in the same folder and use your custom Date file name suffix you set in the Image Processor dialog.  The thing is the jpeg file will be a copy there will two jpeg file with identical content in the folder with different names.  It not a rename.  If you want to add things to the jpeg You can record an action to  add what you want to add to the jpegs and have the Image processor pro include using your action when processing your selected jpeg images.

Capture.jpg

 

Tp add data set up an action toe add the dats to the jpeg. ANy the set to Image Processor Proo.. dialoy toe user it.

Capture.jpg

JJMack

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 ,
Oct 08, 2021 Oct 08, 2021

Copy link to clipboard

Copied

@Sheaffer 

 

If it was just renaming files, then there would be no need to open them into Photoshop. As you wish to add text to the image, you will indeed need to open the files and resave them in Photoshop.

 

Looking at your two sample images, this should be easy enough to script. Would it be acceptable to type the date details into a prompt once per batch, then those details would be applied to the entire batch of input JPEG images in that top-level directory/folder?

 

And just to be crystal clear, do you simply wish to only include " Date" at the end of the current filename, or the actual date string, such as " AUGUST, 2 2021" or whatever the date you enter is?

 

 

Please try the following script, saving as JPEG quality 12. As the example files appear to be from a template, I have also added the feature to remove photoshop:DocumentAncestors metadata from the processed files (which is not a bad thing in itself, however, it can bloat file sizes if there is excessive entries).

 

NOV 28 Downloading and Installing Adobe Scripts

 

/* 
https://community.adobe.com/t5/photoshop-ecosystem-discussions/help-with-photoshop-action-script-or-variable-not-sure/td-p/12439599
Help with Photoshop action, script, or variable not sure

Batch Date Stamp.jsx
v1.0
Stephen Marsh, 9th October 2021
*/

#target photoshop

if (app.documents.length === 0) {

    // The "Test if Cancel..." needs to be within a function
    (function () {

        var savedDisplayDialogs = app.displayDialogs;
        var inputFolder = Folder.selectDialog("Select the input folder containing JPEG files", "");
        // Test if Cancel button returns null, then do nothing
        if (inputFolder === null) {
            app.beep();
            return;
        }

        var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg)$/i);

        // var outputFolder = inputFolder;
        var outputFolder = Folder.selectDialog("Select the output folder", inputFolder);
        // Test if Cancel button returns null, then do nothing
        if (outputFolder === null) {
            app.beep();
            return;
        }

        var dateString = prompt("Enter the date (Month, Day Year)", "MONTH, ## ####");
        // Test if Cancel button returns null, then do nothing
        if (dateString === null) {
            app.beep();
            return;
        }

        app.displayDialogs = DialogModes.NO;

        for (var i = 0; i < inputFiles.length; i++) {
            open(inputFiles[i]);
            var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
            var saveFileJPG = new File(new File(outputFolder + '/' + docName + ' date' + '.jpg'));
            dateStamp();
            // As this appears to be created from a template
            deleteDocumentAncestorsMetadata();
            saveJPG(saveFileJPG);
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        }

        app.displayDialogs = savedDisplayDialogs;

        app.beep();
        alert("Script Completed! Files saved to: " + "\r" + outputFolder.fsName);


        /************ Functions ************/

        function dateStamp() {
            var doc = app.activeDocument;
            // Ruler units
            var origRuler = app.preferences.rulerUnits;
            app.preferences.rulerUnits = Units.POINTS;

            // Doc resolution
            var origRes = app.activeDocument.resolution;
            app.activeDocument.resizeImage(null, null, 72, ResampleMethod.NONE);

            // Text layer, based on a 72ppi resolution
            var layerRef = doc.artLayers.add();
            layerRef.name = "Date Info";
            layerRef.kind = LayerKind.TEXT;
            var textRef = layerRef.textItem;
            var textColor = new SolidColor();
            textColor.rgb.red = 255;
            textColor.rgb.green = 255;
            textColor.rgb.blue = 255;
            textRef.color = textColor;
            textRef.contents = dateString;
            textRef.position = new Array(0, 0);
            textRef.font = 'Arial-Black';
            textRef.size = 50;
            textRef.useAutoLeading = true;
            textRef.justification = Justification.CENTER;

            // Ruler units for positioning on canvas
            app.preferences.rulerUnits = Units.PIXELS;
            // Align text to horizontal centre
            align2SelectAll('AdCH');
            // Align text to bottom
            align2SelectAll('AdTp');
            // move text layer down
            doc.activeLayer.translate(0, 42);

            // Restore original doc resolution
            app.activeDocument.resizeImage(null, null, origRes, ResampleMethod.NONE);
            // Restore original ruler units
            app.preferences.rulerUnits = origRuler;

            function align2SelectAll(method) {
                /*
                AdLf = Align Left
                AdRg = Align Right
                AdCH = Align Centre Horizontal
                AdTp = Align Top
                AdBt = Align Bottom
                AdCV = Align Centre Vertical
                */
                doc.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) { }
                doc.selection.deselect();
            }
        }

        function saveJPG(saveFileJPG) {
            var jpgOptions = new JPEGSaveOptions();
            jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
            jpgOptions.embedColorProfile = true;
            jpgOptions.matte = MatteType.NONE;
            jpgOptions.quality = 12;
            app.activeDocument.saveAs(saveFileJPG, jpgOptions, true, Extension.LOWERCASE);
        }

        function deleteDocumentAncestorsMetadata() {
            // https://prepression.blogspot.com/2017/06/metadata-bloat-photoshopdocumentancestors.html
            // https://forums.adobe.com/message/8456985#8456985
            if (ExternalObject.AdobeXMPScript === undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
            var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);
            xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");
            app.activeDocument.xmpMetadata.rawData = xmp.serialize();
        }

    })();

} else {
    alert('No documents should be open when running this script!');
}

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 ,
Oct 10, 2021 Oct 10, 2021

Copy link to clipboard

Copied

Typing the date detail into a prompt would be perfect! Just the word date so I can distinguish between ones that have dates and don't as they will be uploaded in different locations. If adding the date is easier that would be acceptable as well. Thank you for your help

 

 

Thanks appreciate this and can't wait to try it tommorrow. You said below you decided not to do somethings until you got feedback. I'm fine with stripping meta data and I do want to add a dropshadow on the text or something that will look good no matter what the background looks like. 

 

 

Also if it helps. The font I'm using is Graphik - Bold at 2pt. And all the images are 1in x 0.563 and the resolution 1920. 

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 ,
Oct 10, 2021 Oct 10, 2021

Copy link to clipboard

Copied

I'll await your feedback to avoid multiple code edits.

 

To change the output filename to use the date string, change:

 

var saveFileJPG = new File(new File(outputFolder + '/' + docName + ' date' + '.jpg'));

 

To:

 

var saveFileJPG = new File(new File(outputFolder + '/' + docName + ' ' + dateString + '.jpg'));

 

@Sheaffer 

 

I have added a step to set the ouptut folder, which by default is using the input folder (as the filename is changed, there shouldn't be any concern of overwriting the originals).

 

The script could be modified to simply assume the input folder as output folder, without the prompt to select a folder.

 

Or you may wish to automatically create a sub-directory with a specific name, without any manual prompt etc.

 

The drop-shadow under the text will be incorporated once you have tested and provide feedback, thanks!

 

 

I don't have access to this font, however, I'm guessing you could just change the line from:

textRef.font = 'Arial-Black';

To:

textRef.font = 'Graphik-Bold';

 

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 ,
Oct 11, 2021 Oct 11, 2021

Copy link to clipboard

Copied

I tried running the script and I get the prompts but no output. I ran it both with you original code and with the changes you suggested to no avail. Attatched is a video fo the attempt. I just did a couple of images for a test. 

 

What am I doing wrong? 

 

While you are looking at this is it possible for the code to looking directories and do it to every jpg. 

 

Each show with a date is for example folder name 8.16.2021 WW. And inside that folder are 4 folders each containing jpgs that need the dates. And mp4s that need not be opened. If not I can organize appropriately to use the script.

 

 

Here is a vimeo link if you prefer not to download a file of me running the script: Screen Recording 2021-10-11 at 11.32.25 AM.mov

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 ,
Oct 11, 2021 Oct 11, 2021

Copy link to clipboard

Copied

The script is designed to only process files with a case insensitive jpg/jpeg extension under the top-level directory, not to recurse into sub-directories. Try with the jpeg files at the top level of the selected folder. I could have missed it, I don't recall this being previously stated. Recursing into sub-folders is a little more complex.

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 ,
Oct 11, 2021 Oct 11, 2021

Copy link to clipboard

Copied

@Stephen_A_Marsh 

Thanks for the help. I didn't know that would be a deep process. I'm sorry if as @JJMack applied I made you feel as if you were my employee. I am very appreciative of your help. If you have a tip jar somewhere let me know.

 

Even without that request the script didn't seem to output anything. Which was what I was trying to ask about. 

 

@JJMack I appreciate your protection of those in the community! I rea through the forms a lot and see you helping so many and have learned from your post! Hope you have a great day

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 ,
Oct 11, 2021 Oct 11, 2021

Copy link to clipboard

Copied

@Sheaffer 

 

It is all good, I like to help, I do this as much for my own learning as your benefit.

 

I'll look into this, but as JJMack suggested, I'll probably just hard code the output folder as the input folder for now, or perhaps make a sub-folder... I'll see.

 

As for the output issue... Just make a test folder somewhere. Copy the JPEG files into it. Then run the script and follow the prompts. You should get new files with a " new" added at the end of their name. Do you get the beep and alert message that files were saved to the output folder path?

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 ,
Oct 11, 2021 Oct 11, 2021

Copy link to clipboard

Copied

@Stephen_A_Marsh 

I don't get any beeps. Not even with the date prompt. The date prompt is the last interaction I have. I did the test folder with only jpgs and get the same results. If it's working for you then it's obviously something I'm doing and I can try to figure it out. 

 

I don't have a preference of whether the output is hard coded or not. Since it is adding a different name on it, it can go beside the files in the same folder. 

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 ,
Oct 11, 2021 Oct 11, 2021

Copy link to clipboard

Copied

The date prompt would only beep if cancelled. The beep and alert notifying script completion only happen on a successful run. Perhaps something is wrong with your copy/paste/save of the forum code. To help identify the issue, I have uploaded/attached a new file to this post, rename the extension from .txt to .jsx and use the File  > Scripts > Browse command to run before you invest the time in installing the script.

 

/* 
https://community.adobe.com/t5/photoshop-ecosystem-discussions/help-with-photoshop-action-script-or-variable-not-sure/td-p/12439599
Help with Photoshop action, script, or variable not sure

Batch Date Stamp.jsx
v1.1
Stephen Marsh, 11th October 2021
*/

#target photoshop

if (app.documents.length === 0) {

    // The "Test if Cancel..." needs to be within a function
    (function () {

        var savedDisplayDialogs = app.displayDialogs;
        var inputFolder = Folder.selectDialog("Select the input folder containing JPEG files", "");
        // Test if Cancel button returns null, then do nothing
        if (inputFolder === null) {
            app.beep();
            return;
        }

        var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg)$/i);

        // var outputFolder = inputFolder;
        var outputFolder = Folder.selectDialog("Select the output folder", inputFolder);
        // Test if Cancel button returns null, then do nothing
        if (outputFolder === null) {
            app.beep();
            return;
        }

        var dateString = prompt("Enter the date (Month, Day Year)", "MONTH, ## ####");
        // Test if Cancel button returns null, then do nothing
        if (dateString === null) {
            app.beep();
            return;
        }

        app.displayDialogs = DialogModes.NO;

        for (var i = 0; i < inputFiles.length; i++) {
            open(inputFiles[i]);
            var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
            // var saveFileJPG = new File(new File(outputFolder + '/' + docName + ' ' + dateString + '.jpg'));
            var saveFileJPG = new File(new File(outputFolder + '/' + docName + ' date' + '.jpg'));
            dateStamp();
            // As this appears to be created from a template
            deleteDocumentAncestorsMetadata();
            saveJPG(saveFileJPG);
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        }

        app.displayDialogs = savedDisplayDialogs;

        app.beep();
        alert("Script Completed! Files saved to: " + "\r" + outputFolder.fsName);


        /************ Functions ************/

        function dateStamp() {
            var doc = app.activeDocument;
            // Ruler units
            var origRuler = app.preferences.rulerUnits;
            app.preferences.rulerUnits = Units.POINTS;

            // Doc resolution
            var origRes = app.activeDocument.resolution;
            app.activeDocument.resizeImage(null, null, 72, ResampleMethod.NONE);

            // Text layer, based on a 72ppi resolution
            var layerRef = doc.artLayers.add();
            layerRef.name = "Date Info";
            layerRef.kind = LayerKind.TEXT;
            var textRef = layerRef.textItem;
            var textColor = new SolidColor();
            textColor.rgb.red = 255;
            textColor.rgb.green = 255;
            textColor.rgb.blue = 255;
            textRef.color = textColor;
            textRef.contents = dateString;
            textRef.position = new Array(0, 0);
            textRef.font = 'Arial-Black';
            textRef.size = 50;
            textRef.useAutoLeading = true;
            textRef.justification = Justification.CENTER;

            // Add drop shadow to text
            dropShadow();

            // Ruler units for positioning on canvas
            app.preferences.rulerUnits = Units.PIXELS;
            // Align text to horizontal centre
            align2SelectAll('AdCH');
            // Align text to bottom
            align2SelectAll('AdTp');
            // move text layer down
            doc.activeLayer.translate(0, 42);

            // Restore original doc resolution
            app.activeDocument.resizeImage(null, null, origRes, ResampleMethod.NONE);
            // Restore original ruler units
            app.preferences.rulerUnits = origRuler;

            function align2SelectAll(method) {
                /*
                AdLf = Align Left
                AdRg = Align Right
                AdCH = Align Centre Horizontal
                AdTp = Align Top
                AdBt = Align Bottom
                AdCV = Align Centre Vertical
                */
                doc.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) { }
                doc.selection.deselect();
            }
        }

        function saveJPG(saveFileJPG) {
            var jpgOptions = new JPEGSaveOptions();
            jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
            jpgOptions.embedColorProfile = true;
            jpgOptions.matte = MatteType.NONE;
            jpgOptions.quality = 12;
            app.activeDocument.saveAs(saveFileJPG, jpgOptions, true, Extension.LOWERCASE);
        }

        function deleteDocumentAncestorsMetadata() {
            // https://prepression.blogspot.com/2017/06/metadata-bloat-photoshopdocumentancestors.html
            // https://forums.adobe.com/message/8456985#8456985
            if (ExternalObject.AdobeXMPScript === undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
            var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);
            xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");
            app.activeDocument.xmpMetadata.rawData = xmp.serialize();
        }

        function dropShadow() {
            // x2 shadows, one black-multiply, one white-difference
            var idset = stringIDToTypeID("set");
            var desc21859 = new ActionDescriptor();
            var idnull = stringIDToTypeID("null");
            var ref2126 = new ActionReference();
            var idproperty = stringIDToTypeID("property");
            var idlayerEffects = stringIDToTypeID("layerEffects");
            ref2126.putProperty(idproperty, idlayerEffects);
            var idlayer = stringIDToTypeID("layer");
            var idordinal = stringIDToTypeID("ordinal");
            var idtargetEnum = stringIDToTypeID("targetEnum");
            ref2126.putEnumerated(idlayer, idordinal, idtargetEnum);
            desc21859.putReference(idnull, ref2126);
            var idto = stringIDToTypeID("to");
            var desc21860 = new ActionDescriptor();
            var idscale = stringIDToTypeID("scale");
            var idpercentUnit = stringIDToTypeID("percentUnit");
            desc21860.putUnitDouble(idscale, idpercentUnit, 100.000000);
            var iddropShadowMulti = stringIDToTypeID("dropShadowMulti");
            var list3481 = new ActionList();
            var desc21861 = new ActionDescriptor();
            var idenabled = stringIDToTypeID("enabled");
            desc21861.putBoolean(idenabled, true);
            var idpresent = stringIDToTypeID("present");
            desc21861.putBoolean(idpresent, true);
            var idshowInDialog = stringIDToTypeID("showInDialog");
            desc21861.putBoolean(idshowInDialog, true);
            var idmode = stringIDToTypeID("mode");
            var idblendMode = stringIDToTypeID("blendMode");
            // Multiply blend shadow
            var idmultiply = stringIDToTypeID("multiply");
            desc21861.putEnumerated(idmode, idblendMode, idmultiply);
            var idcolor = stringIDToTypeID("color");
            var desc21862 = new ActionDescriptor();
            // Black shadow
            var idred = stringIDToTypeID("red");
            desc21862.putDouble(idred, 0.000000);
            var idgrain = stringIDToTypeID("grain");
            desc21862.putDouble(idgrain, 0.000000);
            var idblue = stringIDToTypeID("blue");
            desc21862.putDouble(idblue, 0.000000);
            var idRGBColor = stringIDToTypeID("RGBColor");
            desc21861.putObject(idcolor, idRGBColor, desc21862);
            var idopacity = stringIDToTypeID("opacity");
            var idpercentUnit = stringIDToTypeID("percentUnit");
            // Opacity
            desc21861.putUnitDouble(idopacity, idpercentUnit, 50.000000);
            var iduseGlobalAngle = stringIDToTypeID("useGlobalAngle");
            desc21861.putBoolean(iduseGlobalAngle, true);
            var idlocalLightingAngle = stringIDToTypeID("localLightingAngle");
            var idangleUnit = stringIDToTypeID("angleUnit");
            desc21861.putUnitDouble(idlocalLightingAngle, idangleUnit, 90.000000);
            var iddistance = stringIDToTypeID("distance");
            var idpixelsUnit = stringIDToTypeID("pixelsUnit");
            desc21861.putUnitDouble(iddistance, idpixelsUnit, 5.000000);
            var idchokeMatte = stringIDToTypeID("chokeMatte");
            var idpixelsUnit = stringIDToTypeID("pixelsUnit");
            desc21861.putUnitDouble(idchokeMatte, idpixelsUnit, 0.000000);
            var idblur = stringIDToTypeID("blur");
            var idpixelsUnit = stringIDToTypeID("pixelsUnit");
            desc21861.putUnitDouble(idblur, idpixelsUnit, 3.000000);
            var idnoise = stringIDToTypeID("noise");
            var idpercentUnit = stringIDToTypeID("percentUnit");
            desc21861.putUnitDouble(idnoise, idpercentUnit, 0.000000);
            var idantiAlias = stringIDToTypeID("antiAlias");
            desc21861.putBoolean(idantiAlias, false);
            var idtransferSpec = stringIDToTypeID("transferSpec");
            var desc21863 = new ActionDescriptor();
            var idname = stringIDToTypeID("name");
            desc21863.putString(idname, """Linear""");
            var idshapeCurveType = stringIDToTypeID("shapeCurveType");
            desc21861.putObject(idtransferSpec, idshapeCurveType, desc21863);
            var idlayerConceals = stringIDToTypeID("layerConceals");
            desc21861.putBoolean(idlayerConceals, true);
            var iddropShadow = stringIDToTypeID("dropShadow");
            list3481.putObject(iddropShadow, desc21861);
            var desc21864 = new ActionDescriptor();
            var idenabled = stringIDToTypeID("enabled");
            desc21864.putBoolean(idenabled, true);
            var idpresent = stringIDToTypeID("present");
            desc21864.putBoolean(idpresent, true);
            var idshowInDialog = stringIDToTypeID("showInDialog");
            desc21864.putBoolean(idshowInDialog, true);
            var idmode = stringIDToTypeID("mode");
            var idblendMode = stringIDToTypeID("blendMode");
            // Difference blend shadow
            var iddifference = stringIDToTypeID("difference");
            desc21864.putEnumerated(idmode, idblendMode, iddifference);
            var idcolor = stringIDToTypeID("color");
            var desc21865 = new ActionDescriptor();
            // White shadow
            var idred = stringIDToTypeID("red");
            desc21865.putDouble(idred, 255.000000);
            var idgrain = stringIDToTypeID("grain");
            desc21865.putDouble(idgrain, 255.000000);
            var idblue = stringIDToTypeID("blue");
            desc21865.putDouble(idblue, 255.000000);
            var idRGBColor = stringIDToTypeID("RGBColor");
            desc21864.putObject(idcolor, idRGBColor, desc21865);
            var idopacity = stringIDToTypeID("opacity");
            var idpercentUnit = stringIDToTypeID("percentUnit");
            // Opacity
            desc21864.putUnitDouble(idopacity, idpercentUnit, 50.000000);
            var iduseGlobalAngle = stringIDToTypeID("useGlobalAngle");
            desc21864.putBoolean(iduseGlobalAngle, true);
            var idlocalLightingAngle = stringIDToTypeID("localLightingAngle");
            var idangleUnit = stringIDToTypeID("angleUnit");
            desc21864.putUnitDouble(idlocalLightingAngle, idangleUnit, 90.000000);
            var iddistance = stringIDToTypeID("distance");
            var idpixelsUnit = stringIDToTypeID("pixelsUnit");
            desc21864.putUnitDouble(iddistance, idpixelsUnit, 5.000000);
            var idchokeMatte = stringIDToTypeID("chokeMatte");
            var idpixelsUnit = stringIDToTypeID("pixelsUnit");
            desc21864.putUnitDouble(idchokeMatte, idpixelsUnit, 0.000000);
            var idblur = stringIDToTypeID("blur");
            var idpixelsUnit = stringIDToTypeID("pixelsUnit");
            desc21864.putUnitDouble(idblur, idpixelsUnit, 3.000000);
            var idnoise = stringIDToTypeID("noise");
            var idpercentUnit = stringIDToTypeID("percentUnit");
            desc21864.putUnitDouble(idnoise, idpercentUnit, 0.000000);
            var idantiAlias = stringIDToTypeID("antiAlias");
            desc21864.putBoolean(idantiAlias, false);
            var idtransferSpec = stringIDToTypeID("transferSpec");
            var desc21866 = new ActionDescriptor();
            var idname = stringIDToTypeID("name");
            desc21866.putString(idname, """Linear""");
            var idshapeCurveType = stringIDToTypeID("shapeCurveType");
            desc21864.putObject(idtransferSpec, idshapeCurveType, desc21866);
            var idlayerConceals = stringIDToTypeID("layerConceals");
            desc21864.putBoolean(idlayerConceals, true);
            var iddropShadow = stringIDToTypeID("dropShadow");
            list3481.putObject(iddropShadow, desc21864);
            desc21860.putList(iddropShadowMulti, list3481);
            var idlayerEffects = stringIDToTypeID("layerEffects");
            desc21859.putObject(idto, idlayerEffects, desc21860);
            executeAction(idset, desc21859, DialogModes.NO);
        }

    })();

} else {
    alert('No documents should be open when running this script!');
}

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 ,
Oct 12, 2021 Oct 12, 2021

Copy link to clipboard

Copied

@Stephen_A_Marsh I got it to work thanks for your patience. The issue was/is it doesn't like running the script for files that are on my external hard drive. Not sure why but that's not a big issues. 

 

I was able to edit the font and get it to use Graphik and the size I wanted it. Is there an easy line to make it in a bold state. I misspoke before the font is Graphik and then it's bold. 

 

This has been a great help. If it is not too much to ask is it possible to match the drop shadow with my photoshop settings. See attached screenshot.

 

Again this is going to be a huge time saver for me having this script! If you have a way to tip please let me know. 

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 ,
Oct 12, 2021 Oct 12, 2021

Copy link to clipboard

Copied

Here is a function to add a layer style in your style's palette to a layer use it after the text layer is added in his script to add the style you want.

Add the function to the end of the script and add a javascript statement  

addStyle("MyLayerStyle")

after the text layet is added in his script replace MyLayerStyle with the style name you want added the " are required.

 

 

 

function addStyle(Style){
	var idASty = charIDToTypeID( "ASty" );
	    var desc20 = new ActionDescriptor();
	    var idnull = charIDToTypeID( "null" );
	        var ref3 = new ActionReference();
	        var idStyl = charIDToTypeID( "Styl" );
	        ref3.putName( idStyl, Style );
	    desc20.putReference( idnull, ref3 );
	    var idT = charIDToTypeID( "T   " );
	        var ref4 = new ActionReference();
	        var idLyr = charIDToTypeID( "Lyr " );
	        var idOrdn = charIDToTypeID( "Ordn" );
	        var idTrgt = charIDToTypeID( "Trgt" );
	        ref4.putEnumerated( idLyr, idOrdn, idTrgt );
	    desc20.putReference( idT, ref4 );
	try{
		executeAction( idASty, desc20, DialogModes.NO);
	}catch(e){}
}

 

 

 

.

JJMack

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 ,
Oct 12, 2021 Oct 12, 2021

Copy link to clipboard

Copied

Thanks You!

 

I realized it wasn't loading my font at all when I messed with this. Does the font have to be ttf? and not otf to recognize the name? The name in font book is "Graphik" 

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 ,
Oct 12, 2021 Oct 12, 2021

Copy link to clipboard

Copied

If that font is installed on your system the name you use in the script has to be its internals postscript name not "Graphik"

Graphik Font Free Download  I have not idea of what its postscript font name is.

 

This Photoshop script may help you with Postscripts font names  FontNames.jsx

 

var fList = "";
for (var i=0,len=app.fonts.length;i<len;i++) {
    fList = fList + "FontName:   " + app.fonts[i].name + "\nPostscript: " + app.fonts[i].postScriptName + "\n\n";
}
logInfo(fList)
	
function logInfo(Txt){
    try {	
       var file = new File(Folder.desktop + "/FontList.txt"); 
       file.open("w", "TEXT", "????"); 
       //alert(file.encoding);
       file.encoding = "UTF8";
       file.seek(0,2);   
       $.os.search(/windows/i)  != -1 ? file.lineFeed = 'windows'  : file.lineFeed = 'macintosh';
       file.writeln(Txt); 
       if (file.error) alert(file.error);
       file.close();
       file.execute(); 
    }
    catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
};

 

JJMack

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 ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

So the following didn't work?

 

Graphik-Bold 

 

As in:

 

textRef.font = 'Graphik-Bold';

 

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 ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

@Stephen_A_Marsh It did actually but it wasn't working when I first tried it for some reason. And I thought I realized that the problem is "aerial black" is an actual font and I needed "graphik" font in a bold style.

All and all I just did it wrong somehow but that script @JJMack shared is a great resource to have for the future and confirmed to make sure everything started with a capital letter. 

I flew through a month of graphics today faster than before so again thank you so much. 

I was trying to find a tutorial that would show me how to count the sub folders and then loop this code for each sub folder if you have any links to share. I know html, css, basic php but I'm realizing how powerful JavaScript can be for photoshop sp excited to try to learn more! And it be helpful in my web endeavors too! 

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 ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

@JJMack This was perfect thank you so much. It appears that I wasn't capitalizing one of them and it was case sensitive. It's working great now. 

 

I was also able to follow another post where @Stephen_A_Marsh showed how to use Script listeners. I installed a script listener and used that code to get the dropshadow correct! Thanks so much for your all your help!!!

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 ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

It is good to see you are getting into scripting.  I just hack at it it is very powerful. However I'm retired so learning Javascript will not help me make money I rather just hack at it and drinks some wine. There are a few users here the know how to script well their a big help here and have help me out many times.

JJMack

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 ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

@JJMack Retirements goals! 

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 ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

Glad the font is working, case sensitivity can be a killer!

 

I only have a couple of examples of code that processes files in the top-level directory, then recursively processes files in sub-directories. I have spent hours trying to adapt, without a fully workable result. I don't like letting go of a challenge, however, it is killing me!

 

I'd suggest that you search the web and post links back to anything you find.

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 ,
Oct 13, 2021 Oct 13, 2021

Copy link to clipboard

Copied

I plan to rep looking. I'm not really processing files on the top level directory only in all of the sub directors. 

my thought process is to create some sort of a loop or array where:

 

function subfoldercount 

Ask which folder to open

counts subfolders 

Runs the script you created for each folder by 

Settting the var for inputfiles and outputFolder to the subfolder it's running the script for. 

I'll keep searching. I like a good challenge as well. 

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 ,
Oct 17, 2021 Oct 17, 2021

Copy link to clipboard

Copied

How are you doing with with you attempt to process subfolders.    It would be easiest if you save the output file with the stamp on them in the same folder as the Original jpeg file with the jpeg Name with a unique suffix like a date&time stamp the time the script was run.  That way would not have toe create the output file system tree.  For if you use a Folder selection dialog to select the root of  image file tree  it most likely will not a device there will be a Parent Path, the Root Folder  and lower subfolders branches.   If you select and output folder it  to will have a Parent Path, Your selected output Root, Ant you will need to create  the output lower subfolder branch if the doe nor exist before you can save into them. It not the hard to do but You will need to strip off  the input Parent Path and input root and create the output the subfolders thet doe not exist.  The process is not that hard you recurse through the input image tree to create a folder list you will process to create the selected Filelist that you will process using photoshop to add the date stamp on the image

JJMack

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