Help With Ps Script: Copy Group to a New PSD
Hi,
I'm trying to create a script that does the following:
- Checks for any open PSDs; if so, creates a new document named "Clipped Group."
- Iterates through all open PSDs.
- Checks for a group located at the top of the layer stack in current document called "Group 1." (should skip "Clipped Group" PSD)
- Copies "Group 1" (and any contents or masks attached to the group folder) and pastes it into the "Clipped Group" PSD.
I have gotten this far. The script breaks down starting at Line 28. I get an error message saying that "docRef.layerSets[0].copy" is not a function. I've been trying to piece together how to accomplish the above steps by reading the Adobe Photoshop Scripting guide, and checking forums, but I think I lack an understanding of how to use copy() and paste() or if those are even the methods I need. I'm pretty new at this -- if there was a way to work with what I have written so far, that would be great. Any help would be greatly appreciated. Thanks!
//Set Photoshop to use pixel measurements
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
var docRef = app.activeDocument;
function makePackageDoc(filename) {
if (app.documents.length > 0) {
var docHeight = 2000;
var docWidth = 2000;
app.documents.add(docHeight, docWidth, 300, "Clipped Group", NewDocumentMode.RGB, DocumentFill.TRANSPARENT, 1.0, BitsPerChannelType.EIGHT, "test");
};
};
function moveComponentGroup() {
for (var i = 0; i < app.documents.length; i++) { //Script iterates through all open documents.
docRef = app.documents;
var n = app.documents.length;
if (n > 0) {
if (docRef.name == "Clipped Group") {
continue;
};
var x = docRef.layerSets.length;
if ((x > 0) && (docRef.layerSets[0].name == "Group 1" )) {
docRef.layerSets[0].copy();
app.documents["Clipped Group"].paste();
};
};
};
};
makePackageDoc("Clipped Group");
moveComponentGroup();
