Skip to content

Instantly share code, notes, and snippets.

@hiloki
Last active May 23, 2022 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiloki/a74939f2f29de69c24fd1e795c5edcfe to your computer and use it in GitHub Desktop.
Save hiloki/a74939f2f29de69c24fd1e795c5edcfe to your computer and use it in GitHub Desktop.
Figma Plugin scripts: Rename by convention
const selection = figma.currentPage.selection;
selection.forEach(node => {
// Get current name
const srcName = node.name;
// Split by slash e.g. Questionnaire, Age
const splitName = srcName.split('/');
const newName = splitName.map(name => {
// Remove start/end space, and to lowercase
return name.trim().toLowerCase();
})
// Assign new name
node.name = newName.join('/')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment