I'm tryiong to create a macro that will duplicate the selected layer and then link the copy and original together. It's working fine, unless the original layer is already linked to another. In such a case it unlinks the original layer.
Anyone know why the "Link Selected Layers" command is unlinking, or have a work-around for this?
If the layer was already linked with others, it is going to prevent from unlinking it (while linking with its copy):
(aL = (aD = activeDocument).activeLayer).link(aL.duplicate())
I don't know how to implement this into my Recorded Action.
Save it in a file with any name that have .jsx extension. Then you can either move it to Presets / Actions of your Ps folder to Insert Menu Item from File / Scripts in (restarted) Ps or keep in other place to choose .jsx file from disk by File / Scripts menu item when recording an action.
What's wrong with the layer > duplicate layer command?
I tested with 2 layers linked together. Then selected the top layer and duplicated. The result was that all three layers were linked, the original link between the 2 layers was not lost.
After duplication of a layer, select original with a copy and link them. Original one gets unlinked.