• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Combine two psd into one. Keep filename.

Explorer ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

Hey guys, I'm asking again the same question. For some reason my question dissapeared after forum update.

So the idea is to combine together two psd files but keep the filename of the first image input.

Example :  test-me-1.psd + test-me-5.psd = test-me-1.psd(final result)

I found this script here which does a pretty good job till the point of naming the end file : Line 125

 

theFile.saveAs(new File (theFolderThree + "/file" + bufferNumberWithZeros((a + 1), 4) ), psdOpts)

 

Would appreciate some help on how to tweek it so it could save it as I needed.

#target photoshop

// dialog for folder-selection;

var theFolderOne = Folder.selectDialog ("select a folder containing the backgoround images");

var theFolderTwo = Folder.selectDialog ("select a folder containing the foreground images");

var theFolderThree = Folder.selectDialog ("select a folder to save the combined images to");

if (theFolderOne && theFolderTwo && theFolderThree) {

var theFilesOne = theFolderOne.getFiles(checkFor);

var theFilesTwo = theFolderTwo.getFiles(checkFor);

// check if both folders contain the same number of files;

if (theFilesOne.length != theFilesTwo.length) {

alert ("the folders don’t contain the same number of images")

}

// else do the stuff;

else {

// create the psd-options;

psdOpts = new PhotoshopSaveOptions();

psdOpts.embedColorProfile = true;

psdOpts.alphaChannels = false;

psdOpts.layers = true;

psdOpts.spotColors = true;

// run through the files;

for (var a  = 0; a < theFilesOne.length; a++) {

// open background-image;

var theFile = app.open(File(theFilesOne[a]));

theFile.activeLayer = theFile.layers[0];

// place foreground-image;

var idPlc = charIDToTypeID( "Plc " );

var desc6 = new ActionDescriptor();

var idAs = charIDToTypeID( "As  " );

var desc7 = new ActionDescriptor();

var idfsel = charIDToTypeID( "fsel" );

var idpdfSelection = stringIDToTypeID( "pdfSelection" );

var idpage = stringIDToTypeID( "page" );

desc7.putEnumerated( idfsel, idpdfSelection, idpage );

var idPgNm = charIDToTypeID( "PgNm" );

desc7.putInteger( idPgNm, 1 );

var idCrop = charIDToTypeID( "Crop" );

var idcropTo = stringIDToTypeID( "cropTo" );

var idboundingBox = stringIDToTypeID( "boundingBox" );

desc7.putEnumerated( idCrop, idcropTo, idboundingBox );

var idPDFG = charIDToTypeID( "PDFG" );

desc6.putObject( idAs, idPDFG, desc7 );

var idnull = charIDToTypeID( "null" );

desc6.putPath( idnull, new File( theFilesTwo[a] ) );

var idFTcs = charIDToTypeID( "FTcs" );

var idQCSt = charIDToTypeID( "QCSt" );

var idQcsa = charIDToTypeID( "Qcsa" );

desc6.putEnumerated( idFTcs, idQCSt, idQcsa );

var idOfst = charIDToTypeID( "Ofst" );

var desc8 = new ActionDescriptor();

var idHrzn = charIDToTypeID( "Hrzn" );

var idRlt = charIDToTypeID( "#Rlt" );

desc8.putUnitDouble( idHrzn, idRlt, 0.000000 );

var idVrtc = charIDToTypeID( "Vrtc" );

var idRlt = charIDToTypeID( "#Rlt" );

desc8.putUnitDouble( idVrtc, idRlt, 0.000000 );

var idOfst = charIDToTypeID( "Ofst" );

desc6.putObject( idOfst, idOfst, desc8 );

var idAntA = charIDToTypeID( "AntA" );

desc6.putBoolean( idAntA, true );

executeAction( idPlc, desc6, DialogModes.NO );

// save the combined files;

theFile.saveAs(new File (theFolderThree + "/file" + bufferNumberWithZeros((a + 1), 4) ), psdOpts)

theFile.close(SaveOptions.DONOTSAVECHANGES)

}

}

};

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

////// check for psd, tif or jpg //////

function checkFor (theFile) {

if (theFile.name.slice(-4) == ".psd" || theFile.name.slice(-4) == ".tif" || theFile.name.slice(-4) == ".jpg") {return true}

else {return false}

};

////// buffer number with zeros //////

function bufferNumberWithZeros (number, places) {

var theNumberString = String(number);

for (var o = 0; o < (places - String(number).length); o++) {

theNumberString = String("0" + theNumberString)

};

return theNumberString

};

 

TOPICS
Actions and scripting

Views

1.8K

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
Guest
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

Moving to Photoshop Scripting

Edit: cancel that can't find the Photoshop Scripting forum

Votes

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
Explorer ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

yeah it's combined together now under just photoshop 😞 and tagged as actions and scripting

Votes

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
LEGEND ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

Previous Adobe forums were powered by Jive where we could open directly subsection of some general forum.

 

For ex. current Photoshop 'Actions and Scripting' were under:
https://forums.adobe.com/community/photoshop/photoshop_scripting

while Bridge 'Scripting' under:
https://forums.adobe.com/community/bridge/bridge_scripting


Now to access them we have to click appropraite tab / label from main theme.

My question is what url / link to use to open directly subsection of the forum.

For ex. if I don't want to open first General Photoshop Forums, and then 'Actions and Scripting' but that second in no time?

Votes

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
Community Expert ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

Ged, this is sure a temporary situation.  Least ways I hope it is.  There are just 18 forums at the moment

https://community.adobe.com/

clipboard_image_0.png

The Overview pages had all sorts of invaluble links and information. with the Photoshop Overview pager being one of  best examples.  Where do we find that information now?  Where do we send people when they ask about tablet setup as an example?

 

The Premeire Pro forum was another example with an amazing array of useful links on its Overview page.  

 

OK, I have just discovered that if you tick all the options, the list expands dramatically.

clipboard_image_1.png

Votes

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
Guest
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

Nice one Trevor, I was wondering where all the other forums where, now if only they would populate in alphabetical other 🙂

Votes

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
Advocate ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

You guys made a mess with this new forum site we hope that you settle everything quickly it does not work this way.

Votes

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
Guest
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

We are only users like yourself and not Adobe employees and have nothing to do with the design of the site

Votes

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
Explorer ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

Any luck ? Anyone ? Any ideas ?

Votes

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
LEGEND ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

I filled all boxes and still can't find XMP SDK forum:

https://forums.adobe.com/community/design_development/xmp_sdk

Votes

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
Explorer ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

Hey guys, would you mind helping me ? 🙂 I know it's super annoying. Hoppefully they will fix it...there should be a backup somewhere...few of my question are just gone 😞

Votes

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
LEGEND ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

The reason is all posts from between Aug, 22th - Sep, 9th weren't meant to be archived.

Votes

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
Explorer ,
Sep 17, 2019 Sep 17, 2019

Copy link to clipboard

Copied

@Kukurykus can you please have a look on the code above and try to help me ? would appreciate that !

Votes

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
LEGEND ,
Sep 17, 2019 Sep 17, 2019

Copy link to clipboard

Copied

 

theFile.saveAs(File(theFolderThree + '/' + theFile.name.split(/\./)[0]), psdOpts)

 

Votes

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
Explorer ,
Sep 18, 2019 Sep 18, 2019

Copy link to clipboard

Copied

You saved my soul again ! Dude you're amazing ! Now the question is, how the hell I can mark your answer as a solved issue like before ?

Votes

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
LEGEND ,
Sep 19, 2019 Sep 19, 2019

Copy link to clipboard

Copied

Probably not everything works on this forum yet like on Jive. Visit this topic now and then to find new buttons which I hope Adobe is going to provide...

Votes

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
Community Expert ,
Sep 20, 2019 Sep 20, 2019

Copy link to clipboard

Copied

Hi Joshua,

 

There is a “Correct Answer” button at the bottom of each post. If you don’t see it, Expand the Replies or tell us which one to mark and we can do it for you.

 

Jane

 

615CBCE6-CCBF-47AF-94A1-06113BD11EAF.jpeg

Votes

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
Community Expert ,
Sep 21, 2019 Sep 21, 2019

Copy link to clipboard

Copied

LATEST

joshuab10257965 – I have modified the code to save the combined file using the first input filename.

 

It seemed to work fine for a single image, however when combining multiple images, the order was messed up and the files were not "paired" correctly (if that is the expectation). I tried to include .sort() code without success.

 

 

 

// community.adobe.com/t5/Photoshop/Combine-two-psd-into-one-Keep-filename/td-p/10610400

#target photoshop

// dialog for folder-selection;

var theFolderOne = Folder.selectDialog ("select a folder containing the backgoround images");

var theFolderTwo = Folder.selectDialog ("select a folder containing the foreground images");

var theFolderThree = Folder.selectDialog ("select a folder to save the combined images to");

if (theFolderOne && theFolderTwo && theFolderThree) {

var theFilesOne = theFolderOne.getFiles(checkFor);

var theFilesTwo = theFolderTwo.getFiles(checkFor);

// check if both folders contain the same number of files;

if (theFilesOne.length != theFilesTwo.length) {

alert ("the folders don’t contain the same number of images")

}

// else do the stuff;

else {

// create the psd-options;

psdOpts = new PhotoshopSaveOptions();

psdOpts.embedColorProfile = true;

psdOpts.alphaChannels = false;

psdOpts.layers = true;

psdOpts.spotColors = true;

// run through the files;

for (var a  = 0; a < theFilesOne.length; a++) {

// open background-image;

var theFile = app.open(File(theFilesOne[a]));

theFile.activeLayer = theFile.layers[0];

// ADDED BY STEPHEN A. MARSH 2019: Capture the first filename to use when saving the combined file
var theFirstName = theFile.name.replace(/\.[^\.]+$/, ''); 

// place foreground-image;

var idPlc = charIDToTypeID( "Plc " );

var desc6 = new ActionDescriptor();

var idAs = charIDToTypeID( "As  " );

var desc7 = new ActionDescriptor();

var idfsel = charIDToTypeID( "fsel" );

var idpdfSelection = stringIDToTypeID( "pdfSelection" );

var idpage = stringIDToTypeID( "page" );

desc7.putEnumerated( idfsel, idpdfSelection, idpage );

var idPgNm = charIDToTypeID( "PgNm" );

desc7.putInteger( idPgNm, 1 );

var idCrop = charIDToTypeID( "Crop" );

var idcropTo = stringIDToTypeID( "cropTo" );

var idboundingBox = stringIDToTypeID( "boundingBox" );

desc7.putEnumerated( idCrop, idcropTo, idboundingBox );

var idPDFG = charIDToTypeID( "PDFG" );

desc6.putObject( idAs, idPDFG, desc7 );

var idnull = charIDToTypeID( "null" );

desc6.putPath( idnull, new File( theFilesTwo[a] ) );

var idFTcs = charIDToTypeID( "FTcs" );

var idQCSt = charIDToTypeID( "QCSt" );

var idQcsa = charIDToTypeID( "Qcsa" );

desc6.putEnumerated( idFTcs, idQCSt, idQcsa );

var idOfst = charIDToTypeID( "Ofst" );

var desc8 = new ActionDescriptor();

var idHrzn = charIDToTypeID( "Hrzn" );

var idRlt = charIDToTypeID( "#Rlt" );

desc8.putUnitDouble( idHrzn, idRlt, 0.000000 );

var idVrtc = charIDToTypeID( "Vrtc" );

var idRlt = charIDToTypeID( "#Rlt" );

desc8.putUnitDouble( idVrtc, idRlt, 0.000000 );

var idOfst = charIDToTypeID( "Ofst" );

desc6.putObject( idOfst, idOfst, desc8 );

var idAntA = charIDToTypeID( "AntA" );

desc6.putBoolean( idAntA, true );

executeAction( idPlc, desc6, DialogModes.NO );

// save the combined files;

// theFile.saveAs(new File (theFolderThree + "/file" + bufferNumberWithZeros((a + 1), 4) ), psdOpts)

// MODIFIED BY STEPHEN A. MARSH 2019: Use the first filename
theFile.saveAs(new File (theFolderThree + "/" + theFirstName ), psdOpts) 

theFile.close(SaveOptions.DONOTSAVECHANGES)

}

}

};

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

////// check for psd, tif or jpg //////

function checkFor (theFile) {

if (theFile.name.slice(-4) == ".psd" || theFile.name.slice(-4) == ".tif" || theFile.name.slice(-4) == ".jpg") {return true}

else {return false}

};

////// buffer number with zeros //////

function bufferNumberWithZeros (number, places) {

var theNumberString = String(number);

for (var o = 0; o < (places - String(number).length); o++) {

theNumberString = String("0" + theNumberString)

};

return theNumberString

};

 

 

Votes

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