• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to remove the prefix from the active layer name.

Engaged ,
Sep 15, 2020 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

 
TOPICS
Actions and scripting

Views

409

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
community guidelines

correct answers 1 Correct answer

People's Champ , Sep 15, 2020 Sep 15, 2020
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+/, "");

Votes

Translate

Translate
Adobe
People's Champ ,
Sep 15, 2020 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+/, "");

Votes

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
community guidelines
Engaged ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

LATEST

Exactly! Thank you r-bin

Votes

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
community guidelines
Community Expert ,
Sep 15, 2020 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

Votes

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
community guidelines