Copy link to clipboard
Copied
Hi i need a Javascript to select background layer and apply solid color for photoshop CC 2019. Can anyone give code for this,
Thanks in advance.
It looks like you manually changed the name of the first layer and the auto rename is not working. Try this:
for (var i=2;i<=1000;i++)
{activeDocument.activeLayer.name=(activeDocument.activeLayer=activeDocument.activeLayer.duplicate()).textItem.contents=i}
Copy link to clipboard
Copied
1. Create text layer '1' with properties like shadows, strokes, etc
2. Select it on layers palette
3. Run script
for (var i=2; i<=1000;i++)
{(activeDocument.activeLayer= activeDocument.activeLayer.duplicate ()).textItem.contents = i}
Copy link to clipboard
Copied
Omg that's amazing!!! it worked! Thank you!
The only issue I found was that the layers were named:
"1 Copy 1"
"1 Copy 2"
"1 Copy 3"
etc
If there was a name to take the name of the text that's in that layer that would be amazing.
Either way thank you so much you genius!!!
Copy link to clipboard
Copied
It looks like you manually changed the name of the first layer and the auto rename is not working. Try this:
for (var i=2;i<=1000;i++)
{activeDocument.activeLayer.name=(activeDocument.activeLayer=activeDocument.activeLayer.duplicate()).textItem.contents=i}
Copy link to clipboard
Copied
I spoke too soon! that's it! PERFECT TY!!!!! ❤️
Copy link to clipboard
Copied
Sorry I couldn't find a way to edit my message.
I did a little bit of research here: https://graphicdesign.stackexchange.com/questions/33621/restore-photoshop-text-layer-name-auto-updat...
And found that when I select the text tool, click into the layer and just hit escape, it renames the layer the value of the text (if that makes sense). I wonder if there's a script that could sort of emulate this that I can use in conjunction with the last one?
Copy link to clipboard
Copied
I think yot are clicking or double clicking on the layer's name in the layers Palette to edit the layer's name. Try clicking off the name to select the layer. Do not edit the layer name.
Copy link to clipboard
Copied
Great thanks JJmack!
Copy link to clipboard
Copied
@Geekygreek22317303i6i4 wrote:
Sorry I couldn't find a way to edit my message.
I did a little bit of research here: https://graphicdesign.stackexchange.com/questions/33621/restore-photoshop-text-layer-name-auto-updat...
And found that when I select the text tool, click into the layer and just hit escape, it renames the layer the value of the text (if that makes sense). I wonder if there's a script that could sort of emulate this that I can use in conjunction with the last one?
I can't reproduce that and I am not following the problem or request, can you post a screenshot?
Via scripting, text layers can have both a name (.name), and contents (.contents) – which may or may not be "coupled" or even the same.
If this is simply about renaming many existing layers:
https://github.com/Paul-Riggott/PS-Scripts/blob/master/Layer%20Name%20Edit.jsx
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
EDIT: The script posted by jazz-y retains the automated "link" between the text layer content and the text layer name, so if the content is changed the layer name is automatically changed to match. Once the layer name is manually edited, it is no longer "coupled" to the content and will not automatically update with content changes.
Copy link to clipboard
Copied
Sorry that message I posted was after Jazzy figured out the solution for me. I'm all set now, worked perfectly!
Also something I gotta remember going forward, as a couple of you mentioned; I was editing the layer name and not the layer so it caused some of the issues
Copy link to clipboard
Copied
Ah OK then, case closed! Please mark the post/s from jazz-y as the correct answer/s then, thanks.
Copy link to clipboard
Copied
Done, thanks so much!
Copy link to clipboard
Copied
sTT = stringIDToTypeID, cntr = 999; while(cntr)
(dsc2 = new ActionDescriptor()).putString(sTT('name'), 1000 - --cntr),
(dsc1 = new ActionDescriptor()).putObject(sTT('new'), sTT('layer'), dsc2),
dsc1.putBoolean(sTT('copy'), true), executeAction(sTT('make'), dsc1)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now