What's new

batch- play action

#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?
 
#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
 
#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 :)
 
#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){} 
    }
 

Top