Skip to main content
New Participant
July 10, 2017
Question

Script for copying a jpeg and pasting it on another jpeg

  • July 10, 2017
  • 2 replies
  • 2237 views

Hello,

Is there a way to copy a jpeg and paste it on another jpeg for a batch?

Example:

0123_A.jpg to be pasted on 0123.jpg

1234_A.jpg to be pasted on 1234.jpg

2345_A.jpg to be pasted on 2345.jpg

Thanks!!

This topic has been closed for replies.

2 replies

c.pfaffenbichler
Community Expert
July 11, 2017

Also copy/pasting is a poor choice for automation.

Layer > Duplicate Layer or Image > Place … might be faster.

JJMack
Community Expert
July 11, 2017

You would need to give a more details then you have.  Fot if youpast 123_A i=on 123 and both are the same size then save out 12.jpg you would have two jpeg image with 123_A content   The are many threads here one processing pairs of  files. You should search befor asking..

https://forums.adobe.com/search.jspa?place=%2Fplaces%2F1383833&q=paired+jpg

JJMack
New Participant
August 2, 2017

I tweaked a script and I am almost there. It stacks 2 images and saves as a psd and moves on to the next 2 images. Is there a way to keep the stacked images in Photoshop while the script is still working on the other images?

// MAC Finder or WINDOWS Explorer  double click enabled  
#target photoshop 
app.bringToFront(); 

// Variables 
var docRefSup = ""; 
var docRefInf = ""; 
var layerRef = ""; 
var psd_Options  = new PhotoshopSaveOptions(); // [PhotoshopSaveOptions]  
psd_Options.layers  = true; // preserve layers 
psd_Options.embedColorProfile = true; // preserve color profile 
psd_Options.annotations = true; // preserve annotations 
psd_Options.alphaChannels = true; // preserve Alpha channels 
psd_Options.spotColors = true; // preserve Inks 

// Selection the INPUT folder and put the images in an Array 
var inputFolder = new Folder("/G/Images/2014-2015");
var inputFolder = inputFolder.selectDlg();
var outputFolder = Folder(inputFolder + "/../"); 
// Create a directory as OUTPUT folder if it does not exist 
if (!outputFolder.exists) outputFolder.create(); 
var fileList = inputFolder.getFiles(/\.(jpg|jpeg|png|psd|)$/i); 

// Main program 
for (var i= 0;i<fileList.length;i++)  

    docRefSup = open(fileList); 
    docRefInf = open(fileList[i+1]); 
   
    var startRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS; // tell ps to work with pixels

   
    app.activeDocument = app.documents[1]; 
    layerRef = app.activeDocument.activeLayer.bounds;
    app.activeDocument.selection.selectAll()
    app.activeDocument.selection.copy();
    var selectedRegion = Array(Array(layerRef[0].value,layerRef[1].value),Array(layerRef[2].value,layerRef[1].value),Array(layerRef[2].value,layerRef[ 3].value),Array(layerRef[0].value,layerRef[3].value));
    app.activeDocument = app.documents[0];
    app.activeDocument.selection.select(selectedRegion);
    app.activeDocument.paste(true); 
    var fileName  = app.activeDocument.name; 
    // Save the combined file 
   
    app.activeDocument.saveAs(File(outputFolder + '/' + fileName), psd_Options, true ); 
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

    i++; 
}

// Opens PPR Folder
var dir = Folder(inputFolder + "/../"); 
var files = dir.openDlg('This is always the same folder?','',true); 
if( files !=null ){ 
     for(var f = 0;f< files.length;f++){ 
          open(files); 
     } 
}

// END

JJMack
Community Expert
August 3, 2017

laurenrgreen  wrote

I tweaked a script and I am almost there. It stacks 2 images and saves as a psd and moves on to the next 2 images. Is there a way to keep the stacked images in Photoshop while the script is still working on the other images?

Yes.  The File list needs to be even. You would not do two close no-save you would just close the single layer document. After all pairs are processed and save all the layers documents with two layer would still be open in Photoshop.

JJMack