You need to do basically 3 operations:
- traverse through the layers and select them one by one;
- replace a part of the layer name using a regular expression pattern;
- rename the layer with the new name;
A basic* version of this could look like this:
var layer;
// looping through top layers
for (var i = 0; i < activeDocument.layers.length; i++) {
layer = activeDocument.layers[i]; // for ease of read
activeDocument.activeLayer = layer; // making the layer active
layer.name = layer.name.replace(/@.*@/,'##'); // replacing the layer name. @.*@ regex pattern will select anything between two @ symbols
}
Update: replacing the layer text contents.
Basically the same thing with some additions. You need to check if layer.kind
is LayerKind.TEXT
and instead of changing layer.name
you need to change layer.textItem.contents
*. note that activeDocument.layers
collection contains only top level layers. If your document has groups (aka folders) or artboards you'll need to go through nested layers with a different function: something like this