Copy link to clipboard
Copied
Hi everyone! I searched here in the community but couldn't find what I need or something I could change to what I need.
I would be grateful if anyone can help
I have some files, with several layers, but I need to select a specific layer in each of these files.
The names vary, but the ones I need have the final _final in the names.
Ex: Layer 123456_final, another layer, in another file, 5678_final, another abcd_final and so on. the names vary, but the _final is always the same within the files.
Is there any script that recognizes the _final and selects that layer regardless of the name that comes before it?
Thanks!
more letters, but faster:
#target photoshop
s2t = stringIDToTypeID;
(ref = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
ref.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var len = executeActionGet(ref).getInteger(p);
for (var i = 1; i <= len; i++) {
(ref = new ActionReference()).putProperty(s2t('property'), p = s2t('name'));
ref.putIndex(s2t('layer'), i);
if ((/_final$/i).test(executeActionGet(ref).getString(p))) {
(re
...
Copy link to clipboard
Copied
Just a hint... I asked something related in this thread, and the solution seems to be the 'split', which seems followed by regex...
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-delete-the-last-recent-laye...
I had asked to remove only Layer Comps starting with TMP_ (or some specific character, like – )
Copy link to clipboard
Copied
It seems @Kukurykus and @r-bin were most active on above mentioned thread so I will mentioned them to draw their attention. Let me add and @c.pfaffenbichler @Stephen_A_Marsh
Copy link to clipboard
Copied
more letters, but faster:
#target photoshop
s2t = stringIDToTypeID;
(ref = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
ref.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var len = executeActionGet(ref).getInteger(p);
for (var i = 1; i <= len; i++) {
(ref = new ActionReference()).putProperty(s2t('property'), p = s2t('name'));
ref.putIndex(s2t('layer'), i);
if ((/_final$/i).test(executeActionGet(ref).getString(p))) {
(ref = new ActionReference()).putProperty(s2t('property'), p = s2t('layerID'));
ref.putIndex(s2t('layer'), i);
(r = new ActionReference()).putIdentifier(s2t("layer"), executeActionGet(ref).getInteger(p));
(d = new ActionDescriptor()).putReference(s2t("target"), r);
executeAction(s2t("select"), d, DialogModes.NO);
break;
}
}
or less letters, but slower:
lrs=[].slice.call((ad=activeDocument).layers)
while (l=lrs.shift()) if(/_final$/i.test(l.name)) {ad.activeLayer=l; break;}
Copy link to clipboard
Copied
@rrprec – The first question that comes to mind is: what will you do with the selected layer?
The next question is – will there only be 1 layer ending in "_final" – or if there were multiple layers ending in "_final" do you need all of them to be selected?
Copy link to clipboard
Copied
Hi Stephen. Thanks for answering. There Will be lots of layers with that name. I will select one and run an action that changes the name. So i can loop the script to all layers um the file.
Thanks!
Copy link to clipboard
Copied
Thanks, I was wondering "what was next"... Please share your final code.
Copy link to clipboard
Copied
I use separated Scripts and actions. More files, but i think its easier If i have to change things later for my co workers and build new actions. 😉
Copy link to clipboard
Copied
Sure I get it, however, I was interested to see the code to loop over files with the name returned by the script provided by jazz-y. Although it may do the final layer processing, an action can't loop over the files from the script.