Copy link to clipboard
Copied
hi,
How to add save layersets along with Background layer command to this script
Copy link to clipboard
Copied
Have you tried removing the merge visible layers.
Copy link to clipboard
Copied
Yeah I tried that commenting out link but not working it just duplicates only layersets
Copy link to clipboard
Copied
What are you trying to do? Why ae you using that script in the first place. Have you looked a the Image processor, Image processor pro plugin and the Picture processor scripts?
Copy link to clipboard
Copied
I want all my layergroups are duplicated one by one in separate tiff documents.
So that I am using the above one it does it job right now by duplicate the layerset to new document with the layer group name but the problem is is doesn't save those with background.
I had used image processor it doesn't worked for me
Copy link to clipboard
Copied
So your final result, you want a flattened tiff file with each one of your layer sets plus the background layer, correct? If that's the case, I would approach this script (use scriptlistener to record many of the steps) would be to:
1. Have master file open
2. record number of layersets (groups) for a loop.
3. turn off visibility of all layersets.
4. create loop to turn on each layer set in order, have the BG layer visible
5. create a copy of the entire file and use the option to merge visible.
6. Save the copy file and close.
7. Loop continues and turns off visibility of layer set that was just saved and turns on next one. Loop continues.
Copy link to clipboard
Copied
how these many steps can be created using script listener is it possible to create a loop in script listener plugin
Copy link to clipboard
Copied
Merging visible layer i dont want that i want a duplicated layer group and its background from master file.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I mean i use script listener only for doing some functions like photoshop action does
Copy link to clipboard
Copied
Okay, if you want to keep the layers intact, you can do it two different ways:
1. Make a copy of the file but don't use merge visible. Then loop though that copy file and delete all the other layersets and save.
2. Use the copy layers command from the main menu to record copying and moving a layer set to a new file of the same dimension. Copy the background layer also, then save and close.
Copy link to clipboard
Copied
the above script selects the layer groups one by one from top order but its does not select the background while duplicating
thats the main problem please help me on that part
Copy link to clipboard
Copied
You would need to re-program the main function. For each group It would create a new document with a canvas the size of the background layer Using duplicate Background Layer into a new document with the name of the Current Document Name + Group Name. Then duplicate the layers within the current group into that document "Current Document Name + Group Name". If you want to preserve layers you would not want to merge visible. You would need to Save and close "Current Document Name + Group Name" As your layered or flattened Tiff.
The new document containing the Background would be created after statement 6 before statement 7 the dupLayers function would need to the dupe the layers into the document "Current Document Name + Group Name" so that action manager code would need to be changed and have the "Current Document Name + Group Name" be a parameter. You need to change the save as PSD to save as Tiff.
If the bottom layer is actually a Background layer that layer does not support transparency so the Trim transparency statement is not needed. So you can delete 9 and 10. Statement 11 need a little update.
Copy link to clipboard
Copied
Thanks Mack
Can you tell me some example on that part i am confused what function need to set there
Copy link to clipboard
Copied
You need two duplicate layers on duplicates the background into a new document the other duplicates the layer within a group to a document. It needs the be the same document. and doing the dupe will switch to the new document, So after duping the background you nee to switch back to the previous current document document so you can duplicate the groups layers. The current script has one dupe layers and does not name the document. The two dupe you need need to name the same document. So the action manager functions need to have a parameter to name the target document. The for loop in the current script processes each group one at a time.

Copy link to clipboard
Copied
Try this:
#target photoshop
function main(){
if(!documents.length) return;
var doc = activeDocument;
var oldPath = activeDocument.path;
var newName
for(var a=0;a<doc.layerSets.length;a++){
activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets.name);
dupLayers();
var docCopy = activeDocument;
activeDocument = doc
doc.activeLayer = doc.layers[doc.layers.length-1]
doc.activeLayer.duplicate(docCopy,ElementPlacement.PLACEATEND);
activeDocument = docCopy
activeDocument.trim(TrimType.TRANSPARENT,true,true,true,true);
var saveFile= File(oldPath +"/"+doc.layerSets.name +".psd");
SavePSD(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
main();
function dupLayers() {
var desc143 = new ActionDescriptor();
var ref73 = new ActionReference();
ref73.putClass( charIDToTypeID('Dcmn') );
desc143.putReference( charIDToTypeID('null'), ref73 );
desc143.putString( charIDToTypeID('Nm '), activeDocument.activeLayer.name );
var ref74 = new ActionReference();
ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc143.putReference( charIDToTypeID('Usng'), ref74 );
executeAction( charIDToTypeID('Mk '), desc143, DialogModes.NO );
};
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
}
Copy link to clipboard
Copied
Works for me but I would have the original doc name also in the new file names. Perhaps also the value of a for there can be be groups with identical names anf I would do some texsting with nested groups to see how they get done.
Groups within groups remain that way only top level groups have new layered files created. So if want them to be seperate you would need to make this a recursive process somehow.
Copy link to clipboard
Copied
Yea, that would be a good idea.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more