@milevic wrote:
Thanks guys, it works perfect, second one is interesting for me because it changes name of group also
Thanks, that is a natural feature of the command... however, you know how to change the parent group name if you use the code from jazz-y. Same with the code from r-bin.
As an example, extending the code from jazz-y into a function with a variable and a parameter to rename:
dupeWithoutCopy("Duplicate");
function dupeWithoutCopy(theName) {
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t("property"), p = s2t("addCopyToLayerNames"));
r.putClass(s2t("application"));
(d = new ActionDescriptor()).putReference(s2t("target"), r);
var addCopy = executeActionGet(r).getBoolean(p);
d.putBoolean(s2t("addCopyToLayerNames"), false)
executeAction(s2t("set"), d, DialogModes.NO);
executeAction(s2t("copyToLayer"), undefined, DialogModes.NO);
d.putBoolean(s2t("addCopyToLayerNames"), addCopy)
executeAction(s2t("set"), d, DialogModes.NO);
// Rename the active layer
activeDocument.activeLayer.name = theName;
}
Or, extending the code from r-bin:
dupeWithoutCopy("Duplicate");
function dupeWithoutCopy(theName) {
executeAction(stringIDToTypeID("copyToLayer"), undefined, DialogModes.NO);
activeDocument.activeLayer.name = theName;
}