Skip to main content
Known Participant
February 20, 2021
Question

How to automate batch "Merge to HDR Efex Pro 2" from Nik Collection

  • February 20, 2021
  • 3 replies
  • 3181 views

Hello, 

I sometimes make 5 the same photos with different exposure times. Than I use "Merge to HDR Efex Pro 2" from Nik Collection. I use it in this way:

In Photoshop I open the 5 JPG-files. And then:
- FILE

- AUTOMATE

-Merge to HDR Efex Pro 2
In the pop-up screen I than choose for "ADD OPEN FILES"
And after that I have to click a couple of buttons to go to the process.

But my question now is: Is there a way to make a batch process of this? As I sometimes have 50 sets of 5 photos I want to run through this proces. So after I did 1 set of 5 photo's I have to manually open a new set of 5 photo's and run that process.  So I'm looking for a way to have a batch process which would do the same for all the 50 sets. 

I know how to make an action, but the problem is that how I get that action to select 5 different photo's each time?

This topic has been closed for replies.

3 replies

Participant
August 10, 2023

I found a workaround using Pulover's Macro Creator (I'm a Windows user), but it's prone to failures in case of computer lags. 
In a nutsheel: I expand all my stacks selecting the first element of the first stack, then I play my action (set to be repeated for as many times as the number of my open stacks). Once the first stack is processed it get removed (from lightroom, not from the disk!). So - crossing fingers - in the end you will get as many processed TIFFs as you need. Better to do it with a copy of the Lightroom catalogue, because in the end it will be empty. It can be set up easily for a serie of stacks featuring always the same number of elements. Maybe with some extra work it could be fine-tuned to recognize (via OCR) and process stacks of different sizes.     

Participant
April 11, 2024

You sir, @robertom49188862  are a genius!

 

I've been looking for a way to batch the processing of files in LR and HDR Efex for a panorama, and Pulover's Macro Creator works perfectly so far.

 

I've got two extra tips - a) create a smart collection with a flagged condition, then remove the flag at the end of the macro. This gets rid of the processed set with no false deletion possibilities! b) linger a few secodns after the loading parts and before button pressing, to cater for longer loads. This seems to avoid the lag.

 

Great job!

Stephen Marsh
Community Expert
Community Expert
February 20, 2021

Try the following script...

 

IMPORTANT: You must replace the placeholder action name of "Molten Lead" (line 82) to your recorded action name, likewise, you also need to change the action set name from "Default Actions" (line 84) to your recorded action set name. Ensure that you keep the double straight quotes around the names.

 

JPEG, TIFF and PSD files are expected, you can modify the input filter to add more file formats.

 

I have made assumptions regarding the TIFF save options and file output location, filename and suffix. Files are saved to a sub-directory of the input folder named "Batch HDR Output". All of these assumptions can be easily modified, just ask if something does not suit.

 

Input files are required to be alphabetically sorted in order to be correctly processed in the expected sets of 5 images. I.E. A prefix of 0001 to 0005, 0006 to 0010 etc. The quantity of source files must be evenly divisible by 5. There is a manual check for this where you have the option to cancel or continue.

 

Instructions linked at the foot of this post for saving and running scripts.

 

/* 

Batch Merge to Nik HDR Efex Pro 2 v1.jsx
by Stephen Marsh - 2021

How to automate batch 'Merge to HDR Efex Pro 2' from Nik Collection
https://community.adobe.com/t5/photoshop/how-to-automate-batch-quot-merge-to-hdr-efex-pro-2-quot-from-nik-collection/td-p/11845482
https://www.photoshopgurus.com/forum/threads/loading-all-images-in-a-folder-into-groups-of-3-is-it-possible.64634/ - Paul MR
https://forums.adobe.com/thread/2144091
https://forums.adobe.com/message/11236820#11236820

NOTE:
* No Files should be open.
* There is no error checking, the input folder should contain even quantities of 5 alphabetically sorting images.
* DEPENDENCY: An action set/action with the appropriate Nik plug-in settings is required to merge the open files into a single file

*/

#target photoshop

/* Start Open Document Error Check - Part A: If */

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

    // Save and disable dialogs
    var restoreDialogMode = app.displayDialogs;
    app.displayDialogs = DialogModes.NO;

    batchSetProcessing();

    function batchSetProcessing() {

        // Select the input folder
        inputFolder = Folder.selectDialog('Please select the folder with files to process');
        if (inputFolder === null) return;

        // Create the output sub-directory
        var outputFolder = Folder(decodeURI(inputFolder + '/Batch HDR Output'));
        if (!outputFolder.exists) outputFolder.create();

        // Limit the file format input
        var fileList = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|psd)$/i);

        // Force alpha-numeric list sort
        // Use .reverse() for the 1st filename in the merged file
        // Remove .reverse() for the 5th filename in the merged file
        fileList.sort().reverse();

        // Manually validate the input count vs. output count
        var inputCount = fileList.length;
        var cancelScript = confirm(inputCount + ' input files stacked into sets of 5 will produce ' + inputCount / 5 + ' file sets. Press "Yes" to continue or "No" to cancel.');
        // Test if no returns false, then terminate the script
        if (cancelScript === false) {
            alert('Script cancelled!');
            return;
        }

        // Loop through and open the file sets
        while (fileList.length) {
            // Sets of 5 files
            for (var a = 0; a < 5; a++) {
                try {
                    app.open(fileList.pop());
                } catch (e) { }
            }

            processOpenImages();

        }

        // End of script notification
        var outputList = outputFolder.getFiles(/\.(tif|tiff)$/i);
        alert('Script completed!' + '\n' + outputList.length + ' HDR files saved to:' + '\n' + outputFolder.fsName);

        function processOpenImages() {

            try {

                /* Start doing stuff */

                // Play the Nik Merge to HDR Efex Pro 2 action

                // Action to run
                var actionName = 'Molten Lead';
                // Action set to run
                var actionSet = 'Default Actions';
                // Run the nominated action and set
                app.doAction(actionName, actionSet);

                /* Finish doing stuff */

            } catch (e) { }

            // Save name+suffix & save path
            var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
            var saveFile = File(outputFolder + '/' + Name + '_Batch-HDR' + '.tif');

            // Call the save function
            saveTIFF(saveFile);

            // Close all open files without saving
            while (app.documents.length) {
                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            }

            // Function to save TIFF
            function saveTIFF(saveFile) {
                tiffSaveOptions = new TiffSaveOptions();
                tiffSaveOptions.embedColorProfile = true;
                tiffSaveOptions.byteOrder = ByteOrder.IBM;
                tiffSaveOptions.transparency = true;
                // Change .layers to true to preserve layers
                tiffSaveOptions.layers = false;
                tiffSaveOptions.layerCompression = LayerCompression.ZIP;
                tiffSaveOptions.interleaveChannels = true;
                tiffSaveOptions.alphaChannels = true;
                tiffSaveOptions.annotations = true;
                tiffSaveOptions.spotColors = true;
                tiffSaveOptions.saveImagePyramid = false;
                // Image compression = NONE | JPEG | TIFFLZW | TIFFZIP
                tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
                // Save as
                app.activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
            }
        }
    }

    // Restore saved dialogs
    app.displayDialogs = restoreDialogMode;

}

/* Finish Open Document Error Check - Part A: If */


/* Start Open Document Error Check - Part B: Else */

else {

    alert('Batch Merge to Nik HDR Efex Pro 2 v1:' + '\n' + 'Please close all open documents before running this script!');
}

/* Finish Open Document Error Check - Part B: Else */

 

Downloading and Installing Adobe Scripts

AppelmoesAuthor
Known Participant
February 21, 2021

Wow Stephen, that's impressive, respect. I will try the script and let you know. Thanks a million in advance.

Stephen Marsh
Community Expert
Community Expert
February 20, 2021

A script can open multiple files in sets of say 5, and work through all 50 sets. Are the file names alphabetically sorting correctly? If not, there needs to be some sort of way to group them correctly using a text pattern if not numerical/alphabetical sorting...

 

Then the script can play an action to process the open files. The script can then save the combined file and then open up the next set of 5 images and repeat until all 250 files have been processed.

 

What file format and options are you saving the final combined image into? What is the filename based off?

AppelmoesAuthor
Known Participant
February 20, 2021

Hello Stephen,
The files are not always in a logical order, but it's easy for me to rename them to a logical order if that's needed to solve my "problem". For example I can rename them to "000.jpg" till "250.jpg".

The same for the file format, normally it's TIFF but I can make JPG 's of it as well, no problem.

I have tried a lot of programs that record my mouse-clicks and see if that works, but none of them did the job.