leonardpauli / layer-renamer

Find or rename multiple layers at once using RegEx and flags in Sketch
MIT License
51 stars 2 forks source link

See development branch for latest development

LayerRenamer - like a pro   

- a plugin for Sketch

Tested with Sketch v. 45.1

Rename multiple layers at once using RegEx and flags

Select layers - Pro style

Protip: if you skip deselecting, if will look through the ones selected Also: ⌘-enter is faster then clicking the second button


RegEx?

Regular Expressions are very powerful. To learn more and try some more, visit regexr.com. Some worthy mentions:

Flags

Ordered numbers? Dimensions? Find 'n Rename got you covered!

Relative find paths!

Write : in the end of a search expression, followed by any of the following, stacked how many times you desire, to navigate the layer tree:

Transform cases flags

You can transform string cases using flags when replacing. Try writing the following in the replace box: \T $1 this becomes \U uppErcase \E or What?, it should give you ThisBecomes UPPERCASE or What?;

Example workflow: Rename using child layer name

Use case: You've got a bunch of similar structured groups with layers inside of them. All the groups are just called "Group", however the first layer inside has the right name! You would like to rename the parent group to the layers name, and then maybe rename all the layers. No problem with LayerRenamer!

  1. First, select the parent artboard (or just deselect all layers to select the page, if you want to rename the artboards)
  2. cmd-alt-F, and write Grou... + hit enter to select all layers whose name contains "Grou" (ie. Group 1)
  3. cmd-alt-R, keep the first box empty (to choose the whole name), and in the second, write icon %>0.t, hit enter
  4. This will replace all selected groups names with "icon " followed by their first child layer's name (%, flag/start navigate, > children, 0 first, .t title/name)
  5. Now, select all the groups first child; cmd-alt-F, write :>0 (: start navigate, > children, 0 first), and hit cmd-enter to start the filter from the currently selected groups
  6. cmd-alt-R, leave first empty, put image or something in second, hit enter
  7. Enjoy all the extra time you suddenly have left over :)

More advanced:

Beta: Copy outline

Use case: The folder/layer structure you've got in the sidebar could be made to closely resemble the actual markup or css, etc. Together with the plugin, you'll also get an action called "Copy page outline". Just select a parent layer or deselect everything (to export the whole page), then run the action. This is very much just a hint of what to come, nevertheless handy as it is.

Installation

  1. Download and unzip LayerRenamer
  2. Open the .sketchplugin file
  3. Have fun!

Notes

Leave the search/find field empty to match everything Leaving the expression field empty defaults to !path && !artboard

⚠️ Seems like you can't select both layers and their containing group simultaneously. Because of this, if the group is matched (or combined shape container for that matter), it won't match anything inside of it. Add expression !group (or !shape) to search its content instead.

Contribute

Feel like adding / fixing something? Create an issue and/or send a pull request! :D

Say thanks

If you enjoy this plugin, please consider buying me some oatgurt. You can also drop me a line or follow me on Twitter. Got an idea for a new plugin? Send me a tweet!

About

Created by Leonard Pauli, in january 2017, after getting inspired by the RenameIt plugin. Feel free to fork or send pull requests :)