-
Extendscript – Check if Layer Name Exists, Increment Last Integer
Hello, I’m creating a scriptUI panel that sets up a camera rig with 3 null layers and a camera.
In order to get the expressions to reference the correct rig, I set an integer at the end of each layer’s name. (i=1)
Currently I’m prompting the user to enter this number – but I would like the script to check through the comp to see if a rig already exists, and if so, increment the integer at the end of the newly created layer names. (++i)
I’ve racked my brain on how to do this, but I’m not sure how to check for the number at the end of the layer names and hold this value in a variable.
So for example, the initial run of the script would set up these layers:
Heading Null_1
Pitch Null_1
Bank Null_1
Camera_1On the next run of the script, it would see that there is already a rig with 1, so ++i would be 2.
Thanks for any help!