What's new

batch- play action

ciaociao

Active Member
#1
hi eveybody.
I have two folders. in each folder I have 1000 PNG images with transparent background (1000 PNG images in the folder A, 1000 PNG images in the folder B). I need to place the first image in the folder A on top of the first image in the folder B. second image in the folder A on top of the second image in the folder B, and so on, following the right sequence. I would like to do the entire process using the batch function. I need to save the final images in a third folder called "C". what action I need to register in order to get the work done. Could someone tell me what are the steps I need to follow? I saw some old post related to mock ups but my issue is slightly different cause all the images are different and I need to stick to the numbered sequence. thank you very much
 
#2
Can you explain exactly what do you mean by "I need to place the first image in the folder A on top of the first image in the folder B"? As I understand - just open B_01.file and place it as top layer in file A_01.file and save as C_01.file in new folder? That's what you need?
 
#3
couldn't edit my previous post so here goes necessary questions:

1. Is amount of files in each folder exactly the same?
2. Does files have same dimensions?
3. What do you want to do with file when you place it in another file?
 

ciaociao

Active Member
#4
Can you explain exactly what do you mean by "I need to place the first image in the folder A on top of the first image in the folder B"? As I understand - just open B_01.file and place it as top layer in file A_01.file and save as C_01.file in new folder? That's what you need?
HI revnart,
yes... you got it right. I do an example: in the folder A I have 1000 photos/drawings, in the folder B I have 1000 texts. I need to place the texts on top of the photos. the final image obtained by merging the two files ( A_01.file and B_01.file) has to be saved in the folder "C". I use the PNG format in order to keep the transparence
 

ciaociao

Active Member
#7
hi revnart,

1 yes, the amount of files is exactly the same in each folder
2 yes, the files have the same dimensions
3 I need to get text and photos merged down

thanks a lot
 
#9
Ok here is the script that should help you, with progress bar to show you how much time you need ;)
IMPORTANT - You have to make output folder before you run the script.

just copy the code and paste in notepad, then save as file with .jsx extension.
If you will have any problems, just ask ;)

JavaScript:
#target photoshop
app.bringToFront();

//folders
alert('Select "A" folder');
var A_Folder = Folder.selectDialog('Select folder "A"');

alert('Select "B" folder');
var B_Folder = Folder.selectDialog('Select folder "B"');

alert('Select output folder');
var C_Folder = Folder.selectDialog('Select Output folder');

var searchMask = '*.???';

var A_Files = A_Folder.getFiles(searchMask);
var B_Files = B_Folder.getFiles(searchMask);

var psdOptions = new PhotoshopSaveOptions();
psdOptions.layers = true;

var currentNum = 0;
var w = new Window ('palette');
var wfile = w.add ("statictext");
wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " Current Files";
wfile.alignment = 'fill';
w.pbar = w.add ('progressbar', undefined, 0, A_Files.length);
w.pbar.preferredSize.width = 500;
w.show();

for(var i=0;i<A_Files.length;i++){
    var doc = open(A_Files[i]);
    var docName = doc.name;
  
    placeFile (B_Files[i], 100);
  
    doc.activeLayer.blendMode = BlendMode.NORMAL;
    doc.saveAs (new File(C_Folder +'/' + docName.split('.')[0] + '.psd'), psdOptions);
  
     w.pbar.value = i+1;
        currentNum = currentNum + 1;
        wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " " + A_Files[currentNum];
      
    doc.close(SaveOptions.DONOTSAVECHANGES);
    };


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){}
    }
 
#10
Ok here is the script that should help you, with progress bar to show you how much time you need ;)
IMPORTANT - You have to make output folder before you run the script.

just copy the code and paste in notepad, then save as file with .jsx extension.
If you will have any problems, just ask ;)

JavaScript:
#target photoshop
app.bringToFront();

//folders
alert('Select "A" folder');
var A_Folder = Folder.selectDialog('Select folder "A"');

alert('Select "B" folder');
var B_Folder = Folder.selectDialog('Select folder "B"');

alert('Select output folder');
var C_Folder = Folder.selectDialog('Select Output folder');

var searchMask = '*.???';

var A_Files = A_Folder.getFiles(searchMask);
var B_Files = B_Folder.getFiles(searchMask);

var psdOptions = new PhotoshopSaveOptions();
psdOptions.layers = true;

var currentNum = 0;
var w = new Window ('palette');
var wfile = w.add ("statictext");
wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " Current Files";
wfile.alignment = 'fill';
w.pbar = w.add ('progressbar', undefined, 0, A_Files.length);
w.pbar.preferredSize.width = 500;
w.show();

for(var i=0;i<A_Files.length;i++){
    var doc = open(A_Files[i]);
    var docName = doc.name;
 
    placeFile (B_Files[i], 100);
 
    doc.activeLayer.blendMode = BlendMode.NORMAL;
    doc.saveAs (new File(C_Folder +'/' + docName.split('.')[0] + '.psd'), psdOptions);
 
     w.pbar.value = i+1;
        currentNum = currentNum + 1;
        wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " " + A_Files[currentNum];
     
    doc.close(SaveOptions.DONOTSAVECHANGES);
    };


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){}
    }
thanks a lot mate... but I need to ask one more thing... I never used script... when needed I always used this steps
file -> automate -> batch

so what steps do I have to follow with this script?

thanks again :)
 
#11
1a. If you saved jsx file go to step 2.
1b. If you didn't save jsx file download it here - https://adobe.ly/2MuRe9A
2. open Photoshop
3. Go to File>Scripts>Browse.. and choose the jsx file you created/downloaded
4. Script will guide you through the preocess ;)
 
#14
Test it and tell me if this is what you need :)
tested and it works perfectly. but I forgot to say that I need to have the files saved in the folder C in 3 types of format: Jpeg, PNG and PSD.
if this doesn't bother you, I would like also ask if I can change the blendmode. I mean... how can get the main photo in folder A with transparent text in folder B? (so that I can see the color of the surface I print on)
 
#16
Here goes updated script which saves PNG, JPEG and PSD in separate folders, If you post here sample files I will update the script to make the steps you need ;)

JavaScript:
#target photoshop 
app.bringToFront();

//folders
alert('Select folder with Background images');
var A_Folder = Folder.selectDialog('Select folder with Background images');

alert('Select folder with images to place');
var B_Folder = Folder.selectDialog('Select folder with images to place');

alert('Select output folder');
var C_Folder = Folder.selectDialog('Select Output folder');

var searchMask = '*.???'; 

var A_Files = A_Folder.getFiles(searchMask); 
var B_Files = B_Folder.getFiles(searchMask);

var psdOptions = new PhotoshopSaveOptions(); 
psdOptions.layers = true;

var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 10;

var pngOptions = new PNGSaveOptions;
pngOptions.compression = 0;
pngOptions.interlaced = false;

var currentNum = 0;
var w = new Window ('palette');
var wfile = w.add ("statictext");
wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " Current Files";
wfile.alignment = 'fill';
w.pbar = w.add ('progressbar', undefined, 0, A_Files.length);
w.pbar.preferredSize.width = 500;
w.show();

for(var i=0;i<A_Files.length;i++){ 
    var doc = open(A_Files[i]); 
    var docName = doc.name;
    
    placeFile (B_Files[i], 100); 
    
    doc.activeLayer.blendMode = BlendMode.MULTIPLY;
    
    var folderPSD = Folder(C_Folder +'/PSD/');
    if(!folderPSD.exists) folderPSD.create();
    
    var folderJPEG = Folder(C_Folder +'/JPEG/');
    if(!folderJPEG.exists) folderJPEG.create();
    
    var folderPNG = Folder(C_Folder +'/PNG/');
    if(!folderPNG.exists) folderPNG.create();
    
    doc.saveAs (new File(C_Folder +'/PSD/' + docName.split('.')[0] + '.psd'), psdOptions);
        
    doc.flatten();
    doc.saveAs (new File(C_Folder +'/PNG/' + docName.split('.')[0] + '.png'), pngOptions);
    doc.saveAs (new File(C_Folder +'/JPEG/' + docName.split('.')[0] + '.jpg'), jpegOptions);
    
     w.pbar.value = i+1;
        currentNum = currentNum + 1;
        wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " " + A_Files[currentNum];
        
    doc.close(SaveOptions.DONOTSAVECHANGES); 
    };

 
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){} 
    }
 
#17
Here goes updated script which saves PNG, JPEG and PSD in separate folders, If you post here sample files I will update the script to make the steps you need ;)

JavaScript:
#target photoshop
app.bringToFront();

//folders
alert('Select folder with Background images');
var A_Folder = Folder.selectDialog('Select folder with Background images');

alert('Select folder with images to place');
var B_Folder = Folder.selectDialog('Select folder with images to place');

alert('Select output folder');
var C_Folder = Folder.selectDialog('Select Output folder');

var searchMask = '*.???';

var A_Files = A_Folder.getFiles(searchMask);
var B_Files = B_Folder.getFiles(searchMask);

var psdOptions = new PhotoshopSaveOptions();
psdOptions.layers = true;

var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 10;

var pngOptions = new PNGSaveOptions;
pngOptions.compression = 0;
pngOptions.interlaced = false;

var currentNum = 0;
var w = new Window ('palette');
var wfile = w.add ("statictext");
wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " Current Files";
wfile.alignment = 'fill';
w.pbar = w.add ('progressbar', undefined, 0, A_Files.length);
w.pbar.preferredSize.width = 500;
w.show();

for(var i=0;i<A_Files.length;i++){
    var doc = open(A_Files[i]);
    var docName = doc.name;
   
    placeFile (B_Files[i], 100);
   
    doc.activeLayer.blendMode = BlendMode.MULTIPLY;
   
    var folderPSD = Folder(C_Folder +'/PSD/');
    if(!folderPSD.exists) folderPSD.create();
   
    var folderJPEG = Folder(C_Folder +'/JPEG/');
    if(!folderJPEG.exists) folderJPEG.create();
   
    var folderPNG = Folder(C_Folder +'/PNG/');
    if(!folderPNG.exists) folderPNG.create();
   
    doc.saveAs (new File(C_Folder +'/PSD/' + docName.split('.')[0] + '.psd'), psdOptions);
       
    doc.flatten();
    doc.saveAs (new File(C_Folder +'/PNG/' + docName.split('.')[0] + '.png'), pngOptions);
    doc.saveAs (new File(C_Folder +'/JPEG/' + docName.split('.')[0] + '.jpg'), jpegOptions);
   
     w.pbar.value = i+1;
        currentNum = currentNum + 1;
        wfile.text = "[ " + currentNum + "/" +A_Files.length + " ]" + " " + A_Files[currentNum];
       
    doc.close(SaveOptions.DONOTSAVECHANGES);
    };


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){}
    }

Hi mate,
I was away for a little while... I've seen the new script... I test it
today and later I try to make an example for what I need... I just need to figure out how.
a big thanks for your help :)
 

ciaociao

Active Member
#18
Hi there,

the last script you sent to me
was fine but when I see the final image I notice that the image from folder B placed upon the image from folder A is slightly moved from center (the two images have
the same dimensions and in order to get the images perfectly overlapped I need to move the second image manually). is possible to fix this problem?
I don't know anything about java script but comparing the two files you sent me I changed the blending mode from multiply to NORMAL and I canceled doc.flatten in order
to get the png file with transparent background). another issue is that the second image is placed in the right sequence only if the files from folder A and B have the same name
but the files in folder B have different names and I can't change them. is possible to follow the sequence regardless the names?

The way the file are saved in tre different folder is perfect.

if doesnt bother you, could I have 2 different scripts? one picking up files from two folders A and B, saving in C; and one picking up files from tre folders A, B and C?
(image from folder C upon B upon A, the final image saved in folder D)

thanks a lot :)
 
#19
1. As I wrote earlier, I would need one of you "A" files, one of your "B" files and one final file to know exactly what I'm working with ;) That way I will identify why there is some movement.
2. Sequence of names - I will try to add some options to sort files
3. Adding another folder should be a big problem

Probably all you want is possible ;) Just need some time and your files, at least one from each folder.
 

ciaociao

Active Member
#20
about my previous request... I try to explain: I have one png file, I select the file using ctrl and clicking on the layer. I select only the image and use bucket to fill the shape with black colour. but when I do this work I get the blurred shape. I instead need an image with clean and clear cut. I tried different options but nothing works.
I do this without using manually the eraser because I need to automate this action using batch funtion, that's why I use ctrl and click on layer so that I can register the action. how can I sort it out?


I send you 3 images in order to explain better

2 shape with blur.png

2 shape with blurred  contour.png

1 clean cut black.png
 

Top