Refactor and batch rename
Renaming one layer is easy. Renaming 200 layers, or changing the prefix used for every exported file in a project, is not. The refactor sheet can rename layers, materials, pages, constants, export names, and text in one go, with a live preview of every change before anything happens.
To open the refactor sheet, choose File › Refactor (⌃⌘R).
What gets changed #
The checkboxes at the top of the sheet choose what will be changed. Only Layer names is turned on by default.
Layer namesrenames layers and groups.Material namesrenames materials.Page namesrenames pages.Constant namesrenames constants. Constant names can only contain letters and numbers, so anything else is removed.Export nameschanges the file names used when exporting.Text contentschanges the words inside text layers.
The Scope popup sets which parts of the document are affected: Document, Current Page, or Current Selection. Current Selection uses the selected layers, or every layer on the selected pages if no layers are selected. Materials and constants belong to the whole document, so they’re always changed document-wide, whatever the scope. Page names are only limited by scope for Replace Text and Regular Expression.
The Action popup chooses what kind of change to make. Each action is described below.
Replace text #
Replace Text finds text and replaces it with something else. Type what you’d like to find into the Find field, and what you’d like to replace it with into the Replace field. Every occurrence is replaced, and matching isn’t case sensitive.
Add text #
Add Text adds text to the start or end of names. Whatever is typed into the Before field is added to the start, and whatever is typed into the After field is added to the end. Adding icon- before layer names turns home into icon-home.
Sequence #
Sequence replaces names with a numbered sequence. The new name is made from the Before text, a number, and the After text. The first item gets the number in the Start numbers at field, and each item after that goes up by one. With Before set to frame- and Start numbers at set to 1, layers will be renamed frame-1, frame-2, frame-3, and so on.
Please note that sequences replace the whole name, so the original name is lost.
Regular expression #
Regular Expression works like Replace Text, but the Regular Expression field accepts a regular expression, and the Replacement field can use capture groups like $1. Regular expressions are case sensitive.
For example, a regular expression of (.*)-small with a replacement of small-$1 turns button-small into small-button.
Transform #
Transform changes the capitalisation of names. The Transform popup has three options: Lower Case, Upper Case, and Capitalize. Capitalize capitalises the first letter of every word.
Preview and applying changes #
The table at the bottom of the sheet shows every match, with the type of item, what it’s called now, and what it will be called after the change. The preview updates as you type.
Click Refactor to make the changes. If refactoring a collection will change documents that aren’t open, you’ll be asked to confirm by clicking Refactor again. Changes to a document can be undone with Edit › Undo.
Refactoring collections #
The refactor sheet can also be opened from a collection, which lets you make changes across many documents at once. In a collection, the Scope popup has two options: All Documents and Selected Documents, and the preview table also shows which document each change is in.
Documents in the collection that are open can have their changes undone. Documents that aren’t open are opened in the background, changed, saved, and closed. Those changes can’t be undone, so please make sure you have backups or are using version control before refactoring a collection.
Further reading: Collections and layers and groups