Select by part of name

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

Mike Hale

Select by part of name

Post by Mike Hale »

"/" and "\" are just two of the many special chars used in regular expressions. The forward slash is used to start and stop the pattern when creating an implicit RegExp like /lit+.*specular./
That same expression could be created explicitly like this new RegExp(lit+.*specular.). Notice the forward slashes are not used in the last example.

The back slash is used to either give a char a special meaning or take away the special meaning of some chars.

/d/ means match a single 'd' char. /\d/ means match a single digit char( 0-9 )

/./ means match any single char. /\./ means match a single dot char.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Dariusz1989

Select by part of name

Post by Dariusz1989 »

Hmm interesting... thanks !

So I've been scriptig quite a lot and I hit another issue. Not sure why its happening. I got it to work with fixed variables but when I want to reference one it changes belnding mode of everything rather than layer I want...

So this one works

Code: Select allvar doc = app.activeDocument;
layerHolder=[]
Sets =doc.layerSets

function editLayer(docSets) {   
    for (var i=0; i<docSets.length; i++) {
        editLayer(docSets.layerSets);
        for(var a=0; a < docSets.artLayers.length; a++) {
            var layer=docSets.artLayers[a];
            var layerName = docSets.artLayers[a].name;
            if (layerName.match(/.*ABC_123*./)) {
                layerHolder.push(docSets.artLayers[a])
            }
        }
    }

for( var a = 0;a<layerHolder.length;a++){
            layerHolder[a].blendMode = BlendMode.NORMAL;
}

layerHolder=[]

}

editLayer(Sets)


But if I write it this way :

Code: Select allvar doc = app.activeDocument;
layerHolder=[]
Sets =doc.layerSets

function editLayer(docSets,tag) {   
    for (var i=0; i<docSets.length; i++) {
        editLayer(docSets.layerSets);
        for(var a=0; a < docSets.artLayers.length; a++) {
            var layer=docSets.artLayers[a];
            var layerName = docSets.artLayers[a].name;
            if (layerName.match(tag)) {
                layerHolder.push(docSets.artLayers[a])
            }
        }
    }

for( var a = 0;a<layerHolder.length;a++){
            layerHolder[a].blendMode = BlendMode.NORMAL;
}

layerHolder=[]

}

editLayer(Sets,/.*ABC_123*./)

It changes blending mode of everything...

What am I doing wrong here?

Thanks, bye.
Mike Hale

Select by part of name

Post by Mike Hale »

I am not sure that either examples are good ways to write a recursive function. But the problem with the second example is you are not passing the tag argument in the recursive call

editLayer(docSets.layerSets);

should be

editLayer(docSets.layerSets,tag);