Skip to content

Instantly share code, notes, and snippets.

@dannygarcia
Created May 16, 2019 00:18
Show Gist options
  • Save dannygarcia/88a2a6e6fac21de05594993355fe6e0c to your computer and use it in GitHub Desktop.
Save dannygarcia/88a2a6e6fac21de05594993355fe6e0c to your computer and use it in GitHub Desktop.
var sketch = require('sketch')
var document = sketch.getSelectedDocument()
var page = document.selectedPage;
var vFrom = 'v11';
var vTo = 'v12';
var symbols = page.layers.filter(l => l.name.indexOf(vFrom) > -1));
symbols.forEach(s => {
s.name = s.name.replace(vFrom, vTo);
});
// var slice = page.layers[0];
//
// if (slice.type === 'Slice') {
// slice.remove()
// }
var selectedLayers = document.selectedLayers
var selectedCount = selectedLayers.length
if (selectedCount === 0) {
console.log('No layers are selected.')
} else {
console.log('Selected layers:');
selectedLayers.forEach(function (layer, i) {
console.log((i + 1) + '. ' + layer.name)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment