Full credit to @r-bin for the following scripts, I just made some minor adjustments:
Select Similar Layers from Prompt.jsx
/*
Select Similar Layers from Prompt.jsx
Original script by r-bin
https://community.adobe.com/t5/photoshop-ecosystem-discussions/help-with-script-that-select-layers-based-on-string-then-move-selected-layers-to-specific-folder/m-p/12154839
*/
var r_idx = new ActionReference();
var do_it = 0;
// by jazz-y
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayers'));
r.putEnumerated(s2t("document"), s2t("ordinal"), s2t("targetEnum"));
if (executeActionGet(r).getList(p).count) {
var curLayer = activeDocument.activeLayer.name.replace(/(^\D+)(.+$)/, '$1');
} else {
var curLayer = '';
}
var text = prompt("Layer name:", curLayer);
if (text != null)
{
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("selectNoLayers"), d, DialogModes.NO);
for (var i = 0; i < activeDocument.artLayers.length; i++)
if (activeDocument.artLayers[i].name.indexOf(text) >= 0) { r_idx.putIdentifier(stringIDToTypeID("layer"), activeDocument.artLayers[i].id); ++do_it; }
if (do_it)
{
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r_idx);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
//alert(do_it + " layers were selected");
}
Select Similar Layers to Active Layer Name.jsx
/*
Select Similar Layers to Active Layer Name.jsx
Original script by r-bin
https://community.adobe.com/t5/photoshop-ecosystem-discussions/help-with-script-that-select-layers-based-on-string-then-move-selected-layers-to-specific-folder/m-p/12154839
https://community.adobe.com/t5/photoshop-ecosystem-discussions/select-layers-with-the-same-number-name/td-p/12964007
*/
var r_idx = new ActionReference();
var do_it = 0;
var selectedLayerTextPattern = activeDocument.activeLayer.name.match(/^\D+/);
if (selectedLayerTextPattern != null) {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("selectNoLayers"), d, DialogModes.NO);
// Top level layer groups
for (var i = 0; i < activeDocument.layerSets.length; i++)
if (activeDocument.layerSets[i].name.indexOf(selectedLayerTextPattern) >= 0) {
r_idx.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets[i].id);
++do_it;
}
// Top level layers
for (var i = 0; i < activeDocument.artLayers.length; i++)
if (activeDocument.artLayers[i].name.indexOf(selectedLayerTextPattern) >= 0) {
r_idx.putIdentifier(stringIDToTypeID("layer"), activeDocument.artLayers[i].id);
++do_it;
}
if (do_it) {
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r_idx);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
//alert(do_it + " layers were selected");
}
Select Layers Named Noise.jsx
/*
Select Layers Named Noise.jsx
Original script by r-bin
https://community.adobe.com/t5/photoshop-ecosystem-discussions/help-with-script-that-select-layers-based-on-string-then-move-selected-layers-to-specific-folder/m-p/12154839
https://community.adobe.com/t5/photoshop-ecosystem-discussions/select-layers-with-the-same-number-name/td-p/12964007
*/
var r_idx = new ActionReference();
var do_it = 0;
var selectedLayerTextPattern = "Noise";
if (selectedLayerTextPattern != null) {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("selectNoLayers"), d, DialogModes.NO);
// Top level layer groups
for (var i = 0; i < activeDocument.layerSets.length; i++)
if (activeDocument.layerSets[i].name.indexOf(selectedLayerTextPattern) >= 0) {
r_idx.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets[i].id);
++do_it;
}
// Top level layers
for (var i = 0; i < activeDocument.artLayers.length; i++)
if (activeDocument.artLayers[i].name.indexOf(selectedLayerTextPattern) >= 0) {
r_idx.putIdentifier(stringIDToTypeID("layer"), activeDocument.artLayers[i].id);
++do_it;
}
if (do_it) {
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r_idx);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
//alert(do_it + " layers were selected");
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html