Git Product home page Git Product logo

layer-renamer's Introduction

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 your layer(s)
  • Hit ⌘-⎇-R
  • Enter your regex, or just tab if you want it all
  • Enter your replacement pattern
  • Hit enter, and profit!

Select layers - Pro style

  • Deselect all
  • Hit ⌘-⎇-F
  • Enter your regex, flags, and/or relative path
  • Hit enter, and profit!

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:

  • Select all .+
  • Use capture groups item (\d+) (\w+) will match item 57 flower with $1 as 57 and $2 as flower
  • In rename, use the capture groups; $1-icon $2 would give flower-icon 57
  • Adding a prefix or suffix is very simple, check out this question for some demos

Flags

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

  • Using %N in the replacement box, you will get an ordered number, starting with first selected layer as nr 1!
  • Going for reverse? Try %-N
  • Like math? %n makes the counting start as zero :)
  • While we're at it, zero pad with %NN
  • Want the index of the item in the container? Try %I and %i
  • Get what kind of layers it is: %k, or %K for something like Shape/Group/Artboard/Page/Slice/Bitmap/Text/Symbol/SymbolMaster/Path
  • In the search expression, variables locked,hidden, as well as shape etc are available
  • Dimensions! Guess what %x, %y, %w, %h will do?
  • Ready? Get the container/group's properties as well!
  • Just hit %p.t for title/name, or whatever other flag you want!

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:

  • > all children
  • < parent
  • 2 third layer in parent (counting starts at 0)
  • 2n every other layer
  • +1 layer after
  • -4 layer four layers before This means you could write something like this: input (\w+):<+1>3n+1 and in the replacement box write $1 label decoration %I to 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?;

  • \L lowercase, ie. "make the following characters lowercase"
  • \U UPPERCASE
  • \C camelCase
  • \K kebab-case
  • \E end, ie. stop changing the case
  • \S snake_case
  • \T TitleCase
  • \W word 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!

  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 :)

layer-renamer's People

Contributors

leonardpauli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

layer-renamer's Issues

prefix parent name to layers

hi, i been trying to find and replace a string "prefix" with the parent name "Question 1".

Can you show me how its done :)

image

Reverse naming not working (%-N)

Still using this plugin. It's amazing. However, I've run into a bug?

Mac OS High Sierra
Sketch 49.3
Layer renamer 1.3

Steps to reproduce bug

  1. Select layers en open LayerRenamer
  2. Enter a string with %-N in it and click replace all.
  3. No names are changed. It does work when I use %N.

Expected result
The layers are renamed counting down.

not-renaming

Support Sketch 45 plugin update system

Hi there!

This is a quick note to remind you that Sketch 45 will include a plugin update system.

It would be awesome if you could add support to it (it's really easy!) before Sketch 45 comes out. Ideally, you should release an update for your plugin while we're still in Sketch 44, so your users will have a nice & easy experience when 45 is released.

For more details, please check http://sketchplugins.com/d/229-updating-plugins and http://developer.sketchapp.com/introduction/updating-plugins/

Thanks in advance!

Layer-renamer with Artboard name

Hello,
I'm looking to find the code to rename a layer with the artboard name.
Or adding a number of page in the artboard.

Thanks

[Help a poor soul] Question: How to access properties?

Hi, thanks for this plugin!

reading:

Ready? Get the container/group's properties as well!

I don't understand how to get Symbol properties?

I'm trying to use the Name property to rename the layer:

image

That 'Name' is coming from a nested Symbol:

image

Any clues? 🙏

[Feature request] Perpending and appending string

First of all, awesome plugin! I looove ti!

Just a small side note. Not sure how hard would it be supporting the prepending/appending feature. This way users can keep the layer name and simply appending other strings without affecting the original values.

Just a thought ;)

[Feature Request] Select by style; style flags

This is the most mind blowing plugin i've ever seen.
50% of my daily Sketch workflow is to selecting layers.

I suggest to add ability to select layer by layer style

%s.fill == "#000000FF"
%s.rotation > 0
%s.borderRadius == 8
%s.opacity != 1
%s.font == "Helvetica"
%s.shadowBlur == 10
%s.blending == "overlay"
......

[Feature request] Switching to uppercase / lowercase

Is it possible to change a case of а character?
for example, it's possible to do it as described here, but I can't achieve this in your plugin.

e.g. if I want to modify
test sentence -> Test sentence
in sublime text editor I can do it this way:

Find what:
\b(\w)()
Replace with:
\U$1

But this trick doesn't seem to be worked in your plugin...

it renames
test sentence
to
\Utest sentence
instead of making first letter uppercase

Thank you in advance!

v2: new interface

  • use skpm
  • use skpm web view + frameless (or just top bar -less) window
  • integrate rename and search into one
  • use lp-vue-base or similar for web view content
  • use outline from nodenotes with selection/rename preview
  • add parameters, inc symbols, inc rename from tsv etc
  • use always-helpful bottom tooltip
  • expand todo-list
  • etc etc
  • update readme + create gh-pages
  • publish

img_0763


blockers:

I'm using El Capitan which skpm templates doesn't support fully yet because of transpilation issues? Idea: just manually fix the ...arg func apply as my comment on the issue on the troublesome dependency and use it?

Possible to rename children based on parent/group name?

Is it possible to rename the children of a group based on the parent group name?
For example:
issue-list-1 (parent)

issue-list-1-1
issue-list-1-2
issue-list-1-3

This would be incredibly useful when working with Sketch and Principle and you're constantly having to re-import Sketch files.

Cheers,
Pat

Is there a complete manual?

I can't find how to add prefixes and suffixes to layer names without modifying the names themselves (i use that feature in rename tools in Figma and in BulkRenameUtility),
how i can do that in this plugin?

%>0 select sibiling layer instead of child

Hi, I've been having issues with the %>0 selector.

Expected results
Take the name from the first child layer and use that.

Actual results
It takes the name from the sibling.

I didn't have this problem before. Maybe it's because of a Sketch update?

[Feature Request] Add Capital Case Method

It would be great to have a "Capital Case" method to the case replacement methods.

It would work something like this.

Layer Name: "some lame title"

Replacement: "Some Lame Title"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.