After duplicating a layer group, I want to be able to target the child text layers of the subsequent new group. And populate each text layer with new content. None of this seems as straight forward as it would be in Extendscript. What am I missing?
Duplicate Group (new group should be selected afterwards)
Get target layer index
Iterate over all layers by Index in reverse (starting from the groups index)
Check for the layerKind property
Populate Text
Stop iteration when the layer property layerSection is “layerSectionEnd”
Note 1: If you have nested groups inside the group, you need to increase a counter for every “layerSectionStart” and decrease it for every “layerSectionEnd”, if it’s 0 then you’ve reached the end of the (outer) group.
Note 2: If you want to do this in 1 batchPlay call, you can’t get the index (step 2.) in between. Instead you could calculate beforehand how many layers the group has (steps 3-6) so that you know at which index the new group starts after the duplication.
Thanks Simon. That helped me along quite a bit. As these text layers are named (and also only contain) an index, what method would you recommend if I want to use the text layer (ex: 1, or ex: 13) as the index of an array I have for actual text to populate it? Think… mail merge in PS haha.
Thanks for the help!
Sorry about the confusion Simon, I’ll try to clarify with an image also.
I duplicate an initial layer group which contains text layers populated with a number (incidentally they are named with the same number way also).
For this use case, I want to know what number is populated in the given text layer (either by contents, or its layer name), so that I can replace the number in the layer marked “1”, to item 1 of a JSON array.
I hope that helps to clarify a bit more. I’m guessing mapping would be useful here also?