Copy link to clipboard
Copied
I need a way to select the same layer on all open documents. For example, I would like to select the layer 'Main' on my active document, run the script and have the 'Main' layer selected on the rest of the documents (so I can tab through them quickly and edit). I always use the same layer names if that helps. 'Main', 'Curves 1', 'Shadow' (folder with mask), and 'Edits'.
I'm currently doing this using actions but it's messy. I used to have a script that could do this but I haven't been able to find it online after endless searching.
(PS 2017)
You can try this. just put in the layer name in line 2, and it is case sensitive.
#target photoshop
var layerName = 'Main';
var num = app.documents.length;
for(var i = 0;i<num;i++){
app.activeDocument = app.documents;
try{
app.activeDocument.activeLayer = app.activeDocument.layers.getByName (layerName);
}
catch(e){}
}
Copy link to clipboard
Copied
You can try this. just put in the layer name in line 2, and it is case sensitive.
#target photoshop
var layerName = 'Main';
var num = app.documents.length;
for(var i = 0;i<num;i++){
app.activeDocument = app.documents;
try{
app.activeDocument.activeLayer = app.activeDocument.layers.getByName (layerName);
}
catch(e){}
}
Copy link to clipboard
Copied
Thanks for your help with this. This does select the named layer on all of my open documents, and it's way faster than what I had been doing. Very handy! One thing I'm trying to avoid is using multiple scripts/actions to make these selections. Ideally I'd like to be able to select any layer on the active window and with one shortcut/action have it selected on the rest of the documents. I wasn't sure if using the 4 named layers would be easier than using some other (variable?). i'm going to try fiddling with what you gave me
Copy link to clipboard
Copied
The script could be written to use the current target layer name. You would target the layer in the active document and then use you shortcut for the script. The script would get the active document targeted layer name and would try target a layer with that name in the other open documents. One layer with the name would be targeted would be targeted if one exist. Layer name need not be unique so all layer with the name may not be targeted. Just change the script to use the active layer name.
Copy link to clipboard
Copied
YES!! It works!! You guys are amazing. This did the trick = changing var layerName = 'Main'; to var layerName = app.activeDocument.activeLayer.name;
One minor problem is that it doesn't seem to select the layers if they're inside a group, not a big deal unless you guys know of an easy fix.
Copy link to clipboard
Copied
To get a layer in a group, you would have to loop through the layers and find the layer sets, then search that group, and then loop through that group to check for other groups. A bit slower.
Copy link to clipboard
Copied
Can you refine this script to simply list all the currently selected layer sets?
Copy link to clipboard
Copied
app.activeDocument = app.documents[i];