Highlighted

How to remove the prefix from the active layer name.

Participant ,
Sep 15, 2020

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

 
Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional
If the prefix is the first word separated by a space from the rest of the text, then try it.
activeDocument.activeLayer.name = activeDocument.activeLayer.name.replace(/^\S+\s+/, "");

Topics

Actions and scripting

Views

41

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to remove the prefix from the active layer name.

Participant ,
Sep 15, 2020

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

 
Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional
If the prefix is the first word separated by a space from the rest of the text, then try it.
activeDocument.activeLayer.name = activeDocument.activeLayer.name.replace(/^\S+\s+/, "");

Topics

Actions and scripting

Views

42

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Sep 15, 2020

Copy link to clipboard

Copied

If the prefix is the first word separated by a space from the rest of the text, then try it.
activeDocument.activeLayer.name = activeDocument.activeLayer.name.replace(/^\S+\s+/, "");

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Participant ,
Sep 15, 2020

Copy link to clipboard

Copied

Exactly! Thank you r-bin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Sep 15, 2020

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;

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...