- Releases 0
- a plugin for Sketch
Tested with Sketch v. 45.1
Rename multiple layers at once using RegEx and flags
- Select your layer(s)
- Enter your regex, or just tab if you want it all
- Enter your replacement pattern
enter, and profit!
Select layers - Pro style
- Deselect all
- Enter your regex, flags, and/or relative path
enter, and profit!
Protip: if you skip deselecting, if will look through the ones selected
⌘-enter is faster then clicking the second button
Regular Expressions are very powerful. To learn more and try some more, visit regexr.com. Some worthy mentions:
- Select all
- Use capture groups
item (\d+) (\w+)will match
item 57 flowerwith
- In rename, use the capture groups;
$1-icon $2would give
- Adding a prefix or suffix is very simple, check out this question for some demos
Ordered numbers? Dimensions? Find 'n Rename got you covered!
%Nin the replacement box, you will get an ordered number, starting with first selected layer as nr 1!
- Going for reverse? Try
- Like math?
%nmakes the counting start as zero :)
- While we're at it, zero pad with
- Want the index of the item in the container? Try
- Get what kind of layers it is:
%Kfor something like Shape/Group/Artboard/Page/Slice/Bitmap/Text/Symbol/SymbolMaster/Path
- In the search expression, variables
hidden, as well as
shapeetc are available
- Dimensions! Guess what
- Ready? Get the container/group's properties as well!
- Just hit
%p.tfor title/name, or whatever other flag you want!
Relative find paths!
: in the end of a search expression, followed by any of the following, stacked how many times you desire, to navigate the layer tree:
2third layer in parent (counting starts at 0)
2nevery other layer
-4layer four layers before This means you could write something like this:
input (\w+):<+1>3n+1and in the replacement box write
$1 label decoration %Ito rename every third (skipping the first) layer, in the group right after the group containing the selected field. Better yet, it does so even if you would have tens (or thousands...) of those "named input fields with labels having lots of strange decoration"... Ok, but seriously, pretty handy.
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?;
\Llowercase, ie. "make the following characters lowercase"
\Eend, ie. stop changing the case
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!
- First, select the parent artboard (or just deselect all layers to select the page, if you want to rename the artboards)
cmd-alt-F, and write
Grou... + hit
enterto select all layers whose name contains "Grou" (ie.
cmd-alt-R, keep the first box empty (to choose the whole name), and in the second, write
icon %>0.t, hit
- This will replace all selected groups names with "icon " followed by their first child layer's name (
%, flag/start navigate,
- Now, select all the groups first child;
0first), and hit
cmd-enterto start the filter from the currently selected groups
cmd-alt-R, leave first empty, put
imageor something in second, hit
- Enjoy all the extra time you suddenly have left over :)
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.
- Download and unzip LayerRenamer
- Open the
- Have fun!
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.
Feel like adding / fixing something? Create an issue and/or send a pull request! :D
Created by Leonard Pauli, in january 2017, after getting inspired by the RenameIt plugin. Feel free to fork or send pull requests :)
Join the discussion
No Sketchpacks Relay integration found
- 250 downloads all–time
- 1 downloads this week
- 6 downloads this month
About this plugin
LeonardPauli published this plugin 7mos ago.
v1.3.0 is the latest version.
Native updates are supported within Sketch.app.