- Backup your .sketch file, it's going to be destroyed.
- Select all artboards you want to export to .sketch files.
- Run this script and find your new .sketch files on Desktop.
Last active
September 14, 2021 13:19
-
-
Save tadija/751e7b2e85afa099603b0c49574c0ad9 to your computer and use it in GitHub Desktop.
Sketch script for exporting artboards to separate .sketch files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sketch = require('sketch') | |
var Document = require('sketch/dom').Document | |
var currentDocument = sketch.getSelectedDocument() | |
var selectedLayers = currentDocument.selectedLayers | |
if (selectedLayers.length === 0) { | |
console.log('No layers are selected.') | |
} else { | |
selectedLayers.forEach(function (layer, i) { | |
console.log('Exporting document ' + (i + 1) + '. ' + layer.name) | |
var newDocument = new Document() | |
layer.parent = newDocument.selectedPage | |
newDocument.save('~/Desktop/' + layer.name + '.sketch') | |
newDocument.close() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment