Sketch Export Magic

Sketch Export Magic

Steve Stone
Design + Sketch
Published in
3 min readApr 20, 2017

--

When I was using Photoshop/Illustrator for my asset workflow I had to set up all kinds of tricks to make sure things wound up in the correct folder with the correct file name. You know the drill; The endless process of selecting the right artboards or layers to export, save dialogs, output settings, overwriting files, dragging and dropping to the correct asset folder. Ugh.

Sketch has a few tricks up it’s sleeve that makes this process ridiculously easy and consistent. You can use the layer name to specify a directory that the asset will export to? Yup! It’s hands-down one of my favorite magic tricks of Sketch!

Let’s say that you’ve made this super sweet icon.

You’re right — that *is* a super sweet icon!

You’ve set it up to export an SVG (good job!).

Yay!

You can use the layer name to specify not only the filename (myIcon), but the output directory!

These layer names look a little funky — almost like paths…

Sketch is ridiculously smart about this too!

  • It will automatically overwrite your files by default.
  • If the directory doesn’t exist it will create it for you.
  • If layer name has several / then it will create all of the necessary directories that it needs.
  • It even recognizes ../ as a parent directory and will traverse up! You can even do crazy complex traversing: ../../myFolderTwoFoldersBack.

Check out this configuration:

Look where all of these assets will go on a single export.

How to Export

When it comes to exporting, select the assets you want to export and then use the File > Export (⇧+⌘+E) to export only the selected assets.

Yea — I want that icon in all of those places!

Hit Export. Select the path that you’d like to output to:

“Demo” — I’ll totally remember what that folder name is in 6 months…

In my case everything will be exported relative to the “Demo” directory!

Bonus trick

You can use this same trick inside the export panel! The following will export an SVG in all of those folders (like before), plus create a pngs folder and put all of those folders/files in there.

Multiple outputs with different folders.

Sketch is ridiculously cool. You can save a ton of time and frustration by setting up your structure within Sketch, then let your computer do all of the sorting for you. After-all, isn’t that what computers are for?

Let me know if you have any other cool exporting tricks with Sketch!

--

--

Steve Stone
Design + Sketch

Developer at @downloadym, (DYM Games) coffee connoisseur, and aficionado of terrible documentaries