├── .DS_Store ├── Enumerator.sketchplugin └── Contents │ └── Sketch │ ├── manifest.json │ └── script.cocoascript └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottSavarie/Enumerator/6815f1a3a984eec7adf43459af4d44795097f42e/.DS_Store -------------------------------------------------------------------------------- /Enumerator.sketchplugin/Contents/Sketch/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "author" : "Scott Savarie", 3 | "commands" : [ 4 | { 5 | "script" : "script.cocoascript", 6 | "shortcut" : "ctrl alt cmd e", 7 | "name" : "Enumerator", 8 | "handlers" : { 9 | "run" : "onRun" 10 | }, 11 | "identifier" : "com.bohemiancoding.sketch.runscriptidentifier" 12 | } 13 | ], 14 | "menu" : { 15 | "items" : [ 16 | "com.bohemiancoding.sketch.runscriptidentifier" 17 | ], 18 | "title" : "Enumerator" 19 | }, 20 | "identifier" : "com.example.sketch.7662642c-ab6d-439a-acee-4a6b9bf810df", 21 | "version" : "1.1", 22 | "description" : "Enumerate your layer or artboard names based on their x and y position", 23 | "authorEmail" : "scottsavarie@gmail.com", 24 | "name" : "Enumerator", 25 | "homepage": "http://github.com/ScottSavarie/Enumerator", 26 | "updateURL": "https://github.com/ScottSavarie/Enumerator/blob/master/Enumerator.sketchplugin/Contents/Sketch/manifest.json" 27 | } -------------------------------------------------------------------------------- /Enumerator.sketchplugin/Contents/Sketch/script.cocoascript: -------------------------------------------------------------------------------- 1 | var onRun = function(context) { 2 | var doc = context.document 3 | var enteredName = doc.askForUserInput_initialValue("Enter a name you want each layer or artboard to get", "mockup-"); 4 | var selection = context.selection; 5 | var selectionCount = selection.count() 6 | var artboards = Array(); 7 | 8 | if(selectionCount > 0) { 9 | for(var i=0; i < selectionCount; i++) { 10 | artboards[i] = context.selection[i]; 11 | } 12 | 13 | artboards.sort(function(a,b){ return a.frame().x() - b.frame().x()}); 14 | 15 | for (var i = 0; i < selectionCount; i++){ 16 | if(i <= 8){ 17 | var name = enteredName + "0" + (i+1).toString(); 18 | artboards[i].setName(name) 19 | } 20 | else{ 21 | var name = enteredName + (i+1).toString(); 22 | artboards[i].setName(name) 23 | } 24 | } 25 | } 26 | 27 | else { 28 | var pageArtboards = doc.currentPage().artboards(); 29 | for(var i=0; i < pageArtboards.count(); i++) { 30 | artboards[i] = pageArtboards[i]; 31 | } 32 | 33 | artboards.sort(function(a,b){ return a.frame().x() - b.frame().x()}); 34 | 35 | for (var i = 0; i < pageArtboards.count(); i++){ 36 | if(i <= 8){ 37 | var name = enteredName + "0" + (i+1).toString(); 38 | artboards[i].setName(name) 39 | } 40 | else{ 41 | var name = enteredName + (i+1).toString(); 42 | artboards[i].setName(name) 43 | } 44 | } 45 | } 46 | }; 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Enumerator 2 | Rename and number your artboards or layers based on their x,y position 3 | 4 | 5 | 6 | ![img](http://i.imgur.com/yfY98Z1.gif) 7 | 8 | 9 | ## Installation 10 | 11 | 1. Download plugin and double click to install 12 | 13 | 14 | ## Usage 15 | (ctrl + alt + cmd + e) When you have a bunch of artboards, layers, or whatever and you want to give them all a common name + incrementing number (ex: artboard 01, artboard 02, artboard 03, etc.), use this plugin. It'll look at the object’s x, y position and then number them accordingly from top to bottom, left to right. 16 | 17 | If you select layers / artboard it will only rename the selection. If you run it without selecting anything it will rename all Artboards on the current page. 18 | 19 | 20 | ## Contact 21 | 22 | Scott: [@ScottSavarie](https://www.twitter.com/scottsavarie) 23 | --------------------------------------------------------------------------------