Aller au contenu

Layer Regex Node

By Kriss Norde

Layer Regex filters the layers of multilayer files based on their names, using regular expressions. Once a filter is defined, the layers that match the expression can be renamed, kept or removed.

Where to find this node

  • Effects Library: Tools > Layer > Layer Regex
  • Quick add: right-click in the Node Editor → Add Tool > Layer > Layer Regex

Inputs

  • Image 1 (orange) - multilayer source to filter.
  • Image 2 (green) - second multilayer source to filter.

Controls tab

Expression
the filter used to match and locate characters in layer names.
Mode
how the expression is applied. Transform renames or replaces characters, Keep keeps the layers specified by the expression, Remove removes them.
Name Template
the rule applied to the expression, to replace characters or rename layers.
Unmatched
what to do with layers that do not match the expression. Keep keeps them (all the layers remain), Remove removes them, which isolates the layers impacted by the expression.
Tester
shows the result of your expression as you change the parameters.
Conflicts
switches between Image 1 and Image 2. The selected image is output as the node's Default/[Main] layer.

Examples

  • Add a prefix: Expression (.*) and Name Template Right.$1 give Right.Layer1, Right.Layer2. For a suffix, change the order: $1.Right gives Layer1.Right, Layer2.Right.
  • Prefix only some layers: Expression (Right.*) and Name Template Stereo-$1 give Stereo-Right.Layer1.
  • Find and replace: Expression right(.*) and Name Template Left$1 rename right.1, right.2, right.3 to Left.1, Left.2, Left.3. Be careful, any name containing "right" (for example copyright) is renamed too. To target only the start of the name, use ^right(.*): the ^ means "start of the text".
  • Remove (or keep) layers matching several words: Expression (copy|right) with Mode set to Remove removes the layers containing copy or right. With Mode set to Keep, those layers remain and all the others are removed.
  • Ignore case: Expression (?i)(right) captures right whatever the case (Right, RIGHT...).

Use cases

  • Rename the layers of a multilayer file (prefix, suffix, find and replace).
  • Keep or remove layers based on their names.