Copy link to clipboard
Copied
Hello friends! How do I remove only the prefix from the active layer.
Example: "Img myCamada" for "myCamada" only.
It would look something like this script:
however it removes not the prefix but the suffix.
activeDocument.activeLayer.name = activeDocument.activeLayer.name.replace ("any name", "suffix");
Only I need to remove the prefix. Thank you
activeDocument.activeLayer.name = activeDocument.activeLayer.name.replace(/^\S+\s+/, "");
Copy link to clipboard
Copied
activeDocument.activeLayer.name = activeDocument.activeLayer.name.replace(/^\S+\s+/, "");
Copy link to clipboard
Copied
Exactly! Thank you r-bin
Copy link to clipboard
Copied
You stated a Prefix. so there is some that distinguishes the prefix from the rest of the layer name. A space or special character or a length, something . So you need to parse the layer name into its two part. The Prefix and theRest, Then rename the layer therest part.
app.activeDocument.activeLayer.name = theRest;