Duplicate and rename a layer

Hello everybody

Since I’m not good at javascript, I’m looking for a kind soul to help me create a script for the following tasks.

The goal is to create a new empty layer and give it the name of the one I selected before (which is renamed for example “old”).

Why do that ?
This comes from the way I make new poses for my characters (I don’t use onion skins at all).
To create a new pose when working on a character action, I duplicate the panel I just created. On this new panel I replace the pose of the character with a new one. So I create a new layer above the layer containing the pose and draw transparently on this new layer. After that I have to delete the old layer and rename the new one with the correct name… A bit tedious!

A script could help me do this with a simple shortcut!

So here are the steps he could follow:
(I present my query with the “Photoshop script logic” that I am more familiar with)

let’s say there is a layer named “pose” that is currently selected

  • store the name of the selected layer (“pose”)
  • rename this layer “old_pose”
  • create an empty layer above.
  • select this new created layer and name it “pose”
  • Set the light table to active if it is not
    *end of script

Another way to do this could be:

  • store the name of the selected layer (“pose”)
  • rename this layer “old_pose”
  • duplicate this layer (with the “copy layer” function)
  • select this new created layer and name it “pose”
  • select all drawings in this layer
  • erase drawings
  • Set the light table to active if it is not
    *end of script

Many thanks to anyone who could help me :slight_smile: