Skip to main content
Participant
March 8, 2023
Answered

Script to rename artboard from text layer

  • March 8, 2023
  • 1 reply
  • 1544 views

I found a partial bit of the script to rename artboards from a text layer however if you want to apply the script to multiple boards you have to do it one by one. My question is how would I alter this to make it cycle through all artboards?

 

if (activeDocument.activeLayer.parent.typename == "LayerSet")

    activeDocument.activeLayer.parent.name = activeDocument.activeLayer.name;

Credit to r-bin

This topic has been closed for replies.
Correct answer Nick Combs

There might be some confusion because your code is renaming a LayerSet (group folder in the layers panel). Photoshop doesn't have artboards afaik, unlike Illustrator or InDesign.

 

But you can apply what the code is doing by iterating over an array (or collection) of ArtLayers in a for-loop. The wrinkle is Document.artLayers only gives top-level objects and doesn't check inside groups. So we'll need a helper function to recurse into those and find the layers. I've also added a conditional to check if a layer is text, since you mentioned that's a requirement.

 

Code attached as plain txt.

1 reply

Nick CombsCorrect answer
Inspiring
March 8, 2023

There might be some confusion because your code is renaming a LayerSet (group folder in the layers panel). Photoshop doesn't have artboards afaik, unlike Illustrator or InDesign.

 

But you can apply what the code is doing by iterating over an array (or collection) of ArtLayers in a for-loop. The wrinkle is Document.artLayers only gives top-level objects and doesn't check inside groups. So we'll need a helper function to recurse into those and find the layers. I've also added a conditional to check if a layer is text, since you mentioned that's a requirement.

 

Code attached as plain txt.

Stephen Marsh
Community Expert
Community Expert
March 8, 2023
quote

There might be some confusion because your code is renaming a LayerSet (group folder in the layers panel). Photoshop doesn't have artboards afaik, unlike Illustrator or InDesign.


By @Nick Combs

 

Hi Nick, thank you for contributing!

 

You are correct, in Photoshop's DOM, layerSet or layerSets are used to describe three separate layer types:

 

  • Layer Groups
  • Artboards
  • Frames

 

It takes the more esoteric AM code to differentiate between layer sets, artboards and frames.

 

Inspiring
March 10, 2023

Thanks Stephen. Always happy to learn something new!