Move group into another group
Hi all,
Can any one help to create a script to move the group named "Shine" into another group named "Shine All".
Thanks in advance.
Snapshot show for better understanding.

Hi all,
Can any one help to create a script to move the group named "Shine" into another group named "Shine All".
Thanks in advance.
Snapshot show for better understanding.

Does this help?
// move groups of a certain name into group of a certain name;
// 2015, use it at your own risk;
#target "photoshop-70.032"
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var name1 = "Shine";
var targetName = "Shine All";
var targetGroup = layersWithName (targetName);
// if exactly one group qualifies;
if (targetGroup.length == 1) {
// collect groups;
var theGroups = layersWithName(name1);
// process groups;
for (var m = theGroups.length - 1; m >= 0; m--) {
moveTo(theGroups
[1], targetGroup[0][1]); };
}
else {alert ("too many or too few groups called »"+targetName+"«")}
};
////////////////////////////////////
function layersWithName (thisName) {
// the file;
var myDocument = app.activeDocument;
// get number of layers;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
// process the layers;
var theLayers = new Array;
for (var m = 0; m <= theNumber; m++) {
try {
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), m);
var layerDesc = executeActionGet(ref);
var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
// if not layer group collect values;
if (layerSet != "layerSectionEnd" /*&& layerSet != "layerSectionStart"*/ && isBackground != true) {
var theName = layerDesc.getString(stringIDToTypeID('name'));
var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
if (theName == thisName) {
theLayers.push([theName, theID)
}
};
}
catch (e) {};
};
return (theLayers)
};
////// move //////
function moveTo (theLayer, theGroup) {
// get index;
var ref = new ActionReference();
ref.putIdentifier( charIDToTypeID( "Lyr " ), theGroup - 1);
var layerDesc = executeActionGet(ref);
var theIndex = layerDesc.getInteger(stringIDToTypeID("itemIndex"));
// =======================================================
var idmove = charIDToTypeID( "move" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref4 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
ref4.putIdentifier( idLyr, theLayer );
desc5.putReference( idnull, ref4 );
var idT = charIDToTypeID( "T " );
var ref5 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
ref5.putIndex( idLyr, theIndex );
desc5.putReference( idT, ref5 );
var idAdjs = charIDToTypeID( "Adjs" );
desc5.putBoolean( idAdjs, false );
var idVrsn = charIDToTypeID( "Vrsn" );
desc5.putInteger( idVrsn, 5 );
executeAction( idmove, desc5, DialogModes.NO );
};
edited
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.