Skip to main content
Participating Frequently
September 17, 2019
Question

Batch automating sequences of images.

  • September 17, 2019
  • 5 replies
  • 4060 views

Hi all,

 

I'm aware of the basic photoshop function allowing to batch automate images in a file, one by one, sequentially. Part of my work requires me to process four images at a time(say for example, 0117a, 0117b, 0117c, 0117d) down to one single (0117-final) image.

 

Is there a way for me to get batch automate to load four files at a time and then process an action on them? Or would I first have to get Bridge to organise them into files for each image number? Would it equally be possible to do this with a third-party action?

 

Thanks in advance for your help.

 

G

This topic has been closed for replies.

5 replies

Stephen Marsh
Community Expert
Community Expert
November 21, 2019
Stephen Marsh
Community Expert
Community Expert
September 21, 2019

guillems62282138 – I now have a workable solution, however, it is not my preferred solution.

 

I have adapted on of JJMack's photo collage scripts "BatchMultiImageCollage.jsx":

 

http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html

http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.zip

 

Please download the original script package, as there is a supporting script required (plus you may find other scripts useful too).

 

You'll need to create a "template" file that has a flattened Background layer. This template file will also need to have 4 blank/white alpha channels named Image 1 and Image 2 and Image 3 and Image 4 and will need to be the same pixel dimensions/resolution/orientation as the image sets being processed.

 

The script has a GUI, where you will select the template file, the input folder and an output folder to save the files to.

 

The modified script will use the upper/top/front layer name for the final file, removing the alpha character suffix and adding " Final" to the name.

 

i.e.:

 

5678A.jpg
5678B.jpg
5678C.jpg
5678D.jpg
9876a.jpg
9876b.jpg
9876c.jpg
9876d.jpg

 

5678 Final.psd

9876 Final.psd

 

You can enter the name of the action set and action into the script so that the 4 stack layered file is processed before saving, or additional scripting code could be entered as well.

 

If there is interest, I'll post a link to the modified script as it is too large to comfortably post.

 

Participating Frequently
September 23, 2019

Thank you so much - this sounds perfect. I'll test it this week and let you know how it goes! I've had a read of the script already and it looks ideal .

 

I think I've figured out where I could add the action I'd need to play, around line 553 or so. This was really the crux of what I needed though. 

Stephen Marsh
Community Expert
Community Expert
September 23, 2019

You can find the modified code here:

 

https://gist.github.com/MarshySwamp/b07e0cf6b1a0765c5ba84909c266a89c

 

https://gist.githubusercontent.com/MarshySwamp/b07e0cf6b1a0765c5ba84909c266a89c/raw/039346f0a57c079b89e86fcdc0d7f0b0b078a190/Layer%2520Stack%2520N%2520Number%2520of%2520Files%2520-%2520Filename%2520as%2520Top%2520Layer.jsx

 

The support script is here, as well as in JJMack's previously linked .zip archive:

 

https://gist.github.com/MarshySwamp/47aed30f86a36645d2d91e3f75452507

 

https://gist.githubusercontent.com/MarshySwamp/47aed30f86a36645d2d91e3f75452507/raw/6612d6f8ad7d8a0f9cf5d5a41107fa31c4f85c76/PCTpreferences.jsx

 

I added two extra blocks of code to JJMack's original script:

 

The original script was not processing in alphabetical order, it was mixing up the image sets, so I added a forced sort:

 

 

 

//////////////////////////////////////////////////////////////

             // Enforce Alpha-numeric Sort - ADDED BY STEPHEN A. MARSH 2019
             fileList.sort();
             
////////////////////////////////////////////////////////////// 

 

 

 

And here is the "major" addition, you will need to uncomment/remove the // double forward slashes from the line

 

//app.doAction("MyAction", "MyActionSet.atn");

 

Then replace the MyAction and MyActionSet.atn with your specific action.

 

 

 

//////////////////////////////////////////////////////////////   

                           // Layer Name from Top Layer with Digits Removed - ADDED BY STEPHEN A. MARSH 2019
                           var doc = app.activeDocument;
                           doc.activeLayer = doc.layers[doc.layers.length = 0]; // Select the top layer
                           var layerName = doc.activeLayer.name.replace(/[a-z]+$/ig, ''); // Regex to remove single or multiple consecutive case insensitive alphabetical characters from the end of the layer name when used in the filename
                           // doc.activeDocument.backgroundLayer.remove(); // Remove the Background layer
                           doc.activeLayer = doc.layers[doc.layers.length-1]; // Select the back layer
                           doc.activeLayer.remove(); // Remove the active layer
                           doc.channels.removeAll(); // delete alphas  
                           
////////////////////////////////////////////////////////////// 

                           // Play Action - ADDED BY STEPHEN A. MARSH 2019
                           //app.doAction("MyAction", "MyActionSet.atn"); // Change the action and action set as required
                           
                           // Or add additional code to do something else to the layered sequence stack before saving...
                           
//////////////////////////////////////////////////////////////  

                           //Save output file - MODIFIED BY STEPHEN A. MARSH 2019
						outputFile = outputFolder + "/" + layerName + " Final";
                        
//////////////////////////////////////////////////////////////  

 

 

Stephen Marsh
Community Expert
Community Expert
September 19, 2019

I'm still looking into this... I am creating a new reply as the threaded reply's to a reply may be missed.

 

I'm only a newb to scripting, so my attempts to modify an existing file input loop that is based on 2 files have not worked for 4 files.

 

If anybody can offer a snipped of generic sample code to open a source folder of files into groups of 2, 3, 4 or more layers that would be very helpful to the community.

 

I have had to go to "Plan B", which is to adapt another totally different script for this purpose... I have been able to successfully combine the input folder into alphabetically sorted groups of 4 layers and save out a .PSD file.

Stephen Marsh
Community Expert
Community Expert
September 17, 2019

Four separate images open at a time... Or do you simply require a single open image with four layers? The action and batch command will do everything else?

 

Is the source a single folder?

 

Do all of the files sort correctly alphabetically?

 

Is the total file count evenly divisible by four?

 

Do the layers need to be in a specific order from bottom to top?

 

Are the images all the same width/height/orientation?

 

Does the layered file need the suffix alphabetical character/letter removed so that the filename only consists of digits/numbers? Are there variations on file name patterns or is the naming consistent?

Participating Frequently
September 18, 2019

It doesn't really matter for me if they open in PS as four separate images, or one image with four layers. The photoshop action groups them into on image of four layers if needed, does everything else, saves, and closes.

 

The source is a single folder, and the files are sorted numerically, 1 through to about 1250, with each number having an a, b, c and d file, if that makes sense. So 00001a, 00001b... 00001d through to 01250a, 01250b, 01250c and 01250d. The total file count is thus divisible by four.

 

The layers need to be in a specific order, yes, so that the "a" image is loaded in first. I could easily re-write the action i use though, if the layers came in differently, so long as they came through in the same order for each set of four.

 

All the images are the same height, width and orientation.

 

The naming is consistent, and the final product has the file number with a suffix on it.

 

Thanks for your help!

Stephen Marsh
Community Expert
Community Expert
September 18, 2019

OK, I’ll presume the following then:

 

* Single source folder

 

* Alphabetical sort

 

* No specific layer order if combined into a single-layered image

 

However, you also mentioned changing the file-name:

 

So, does the layered file need the suffix alphabetical character/letter removed so that the filename only consists of digits/numbers? Are there variations on file name patterns or is the naming consistent?

 

 

Kevin Stohlmeyer
Community Expert
Community Expert
September 17, 2019

Have you tried using the Load Files into Stack script from the File menu? You could add to an action with a pause allowing you to choose the images then continue with the rest of the action. There is no way to completely automate this without scripting but this is close.

Participating Frequently
September 18, 2019
That's the thing - I'm looking to completely automate it. For this project, it's around 5000 images being processed in groups of four down to about 1250 images, so ideally it'd be a script which can group those images into four, load them into photoshop and then run the action I have for them.