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

Layer name not match a string

Contributor ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Hi!

Trying to not remove some layers if name contains, I need some help

What regex needed for the "Notmatch" ?

app.activeDocument.layerSets[0].layers[i].name.match(Notmatch)

 

#target photoshop  
var docRef = app.activeDocument; 
var layName = docRef.activeLayer.name 
var Notmatch = "Invert"  
for(var i = 0; i < app.activeDocument.layerSets[0].layers.length ; i++) {
if(app.activeDocument.layerSets[0].layers[i].name!=layName && app.activeDocument.layerSets[0].layers[i].name.match(Notmatch)){
app.activeDocument.layerSets[0].layers[i].remove();
	}
}

 

TOPICS
Actions and scripting

Views

442

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

correct answers 1 Correct answer

Contributor , Nov 17, 2022 Nov 17, 2022

I think I found it 🙂

#target photoshop 
var docRef = app.activeDocument; 
var layName = docRef.activeLayer.name 
var Notmatch = "Invert"    
for(var i = 0; i < app.activeDocument.layerSets[0].layers.length ; i++) {
if(app.activeDocument.layerSets[0].layers[i].name!=layName && app.activeDocument.layerSets[0].layers[i].name.indexOf(Notmatch)){
app.activeDocument.layerSets[0].layers[i].remove();
}
}

 

 

Likes

Translate

Translate
Contributor ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

LATEST

I think I found it 🙂

#target photoshop 
var docRef = app.activeDocument; 
var layName = docRef.activeLayer.name 
var Notmatch = "Invert"    
for(var i = 0; i < app.activeDocument.layerSets[0].layers.length ; i++) {
if(app.activeDocument.layerSets[0].layers[i].name!=layName && app.activeDocument.layerSets[0].layers[i].name.indexOf(Notmatch)){
app.activeDocument.layerSets[0].layers[i].remove();
}
}

 

 

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