Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Combine two similarly numbered images within different folders into a series of PSD files

New Here ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

Self Explanatory,

 

I have folder A with X number of Images, numbered Sequentially starting at 0

I have folder B with X number of Images, numbered Sequentially starting at 0

 

I would like to:

 

1. Open images A0 and B0

2. Duplicate layer 1 from B0 as a new layer into A0 (duplicate used to preserve image alignment)

3. Save the resulting two layer document as a seperate PSD file.

4. Repeat the Process for [A1, B1], [A2, B2], [A3, B3], etc. until X number of images are combined and saved as individual PSD files.

 

I understand from reading other forums that Automate (Batch) is most likely not powerful enough for this (which I have been using sucessfuly up until now) and a script is most likely required. I have seen various similar examples on these forums of people trying (with various levels of sucess to do this) but with my lack of scripting experience, I have been unable to adapt any of the scripts I have seen for my specific purpose. The script that I thought looked closest to what I want was this one:

 

Batch process groups of files based on numbering

 

What I am aiming for the script to do is:

 

1. Select folder A

2. Select folder B

3. Complete earlier steps until no more images left.

 

An error checker will be unecessary for my application. If it is easy, I would like the script to support combining images from an indeterminate number of folders, but this is not essential.

 

As I said, I lack the experience to make this work properly, and any help would be greatly appreciated.

TOPICS
Actions and scripting, Windows

Views

41

Likes

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 1 Correct answer

Adobe Community Professional , Aug 09, 2021 Aug 09, 2021
@Remulscion – Try this for starters: //community.adobe.com/t5/photoshop/auto-merge-files/m-p/10753387 // Auto merge files // Reference code: // https://forums.adobe.com/thread/2116421 // https://forums.adobe.com/message/8597315#8597315 #target photoshop var folder1 = Folder.selectDialog("Please select the base folder with files to process"); // input folder 1 var folder2 = Folder.selectDialog("Please select the layered folder with files to process"); // input folder 2 var saveFolder = Fo...

Likes

Translate

Translate
Adobe Community Professional ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

@Remulscion – Try this for starters:

 

//community.adobe.com/t5/photoshop/auto-merge-files/m-p/10753387
// Auto merge files

// Reference code:
// https://forums.adobe.com/thread/2116421
// https://forums.adobe.com/message/8597315#8597315

#target photoshop

var folder1 = Folder.selectDialog("Please select the base folder with files to process");  // input folder 1
var folder2 = Folder.selectDialog("Please select the layered folder with files to process");  // input folder 2 
var saveFolder = Folder.selectDialog("Please select the folder to save to...");  // output folder
var searchMask = '*.???';
var list1 = folder1.getFiles(searchMask);
var list2 = folder2.getFiles(searchMask);
list1.sort(); // Alpha-numeric sort
list2.sort(); // Alpha-numeric sort

app.displayDialogs = DialogModes.NO;

var psdOptions = new PhotoshopSaveOptions();
psdOptions.embedColorProfile = true;
psdOptions.alphaChannels = true;
psdOptions.layers = true;
psdOptions.spotColors = true;

for (var i = 0; i < list1.length; i++) {
    var doc = open(list1[i]);
    var docName = doc.name;
    placeFile(list2[i], 100);
    // do stuff to combined layers here  
    doc.saveAs(new File(saveFolder + '/' + docName.split('.')[0] + '.psd'), psdOptions);
    doc.close(SaveOptions.DONOTSAVECHANGES);
};

alert('Script completed!' + '\n' + 'Files saved to:' + '\r' + saveFolder.fsName);

function placeFile(file, scale) {
    try {
        var idPlc = charIDToTypeID("Plc ");
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        desc2.putPath(idnull, new File(file));
        var idFTcs = charIDToTypeID("FTcs");
        var idQCSt = charIDToTypeID("QCSt");
        var idQcsa = charIDToTypeID("Qcsa");
        desc2.putEnumerated(idFTcs, idQCSt, idQcsa);
        var idOfst = charIDToTypeID("Ofst");
        var desc3 = new ActionDescriptor();
        var idHrzn = charIDToTypeID("Hrzn");
        var idPxl = charIDToTypeID("#Pxl");
        desc3.putUnitDouble(idHrzn, idPxl, 0.000000);
        var idVrtc = charIDToTypeID("Vrtc");
        var idPxl = charIDToTypeID("#Pxl");
        desc3.putUnitDouble(idVrtc, idPxl, 0.000000);
        var idOfst = charIDToTypeID("Ofst");
        desc2.putObject(idOfst, idOfst, desc3);
        var idWdth = charIDToTypeID("Wdth");
        var idPrc = charIDToTypeID("#Prc");
        desc2.putUnitDouble(idWdth, idPrc, scale);
        var idHght = charIDToTypeID("Hght");
        var idPrc = charIDToTypeID("#Prc");
        desc2.putUnitDouble(idHght, idPrc, scale);
        var idAntA = charIDToTypeID("AntA");
        desc2.putBoolean(idAntA, true);
        executeAction(idPlc, desc2, DialogModes.NO);

    }
    catch (e) { }
}//end function placeFile

 

Downloading and Installing Adobe Scripts

Likes

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 ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

Thank you very much, this did exactly what I wanted!

Likes

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 Professional ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

LATEST

@Remulscion 

 

Glad it worked for you!

 

It uses File/Place... but it could just as easily use layer duplicate if there was only a single layer.

 

Please mark the reply as the "correct answer" to help others in the future searching for an answer.

Likes

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