sketchplugins / plugin-requests

A collection of plugins requested to our Twitter account
https://twitter.com/sketch
MIT License
211 stars 64 forks source link

Export all files in a folder to PNGs #6

Closed fieryred29 closed 9 years ago

fieryred29 commented 9 years ago

Is there a working plugin to export all files in a folder to PNGs? I tried running the code below from the "run custom script" dialog and I couldn't even get it to run for a single file.

I kept getting the error ReferenceError: Can't find variable: com line: 12 sourceURL: /Users/username/Library/Containers/com.bohemiancoding.sketch3/Data/Library/Application Support/com.bohemiancoding.sketch3/Plugins/Untitled.sketchplugin column: 22

// Export all artboards in ...

@import 'library/common.js'

var doc = doc || context.document, selection = selection || context.selection

if ([doc fileURL] == null) { alert("You need to save your document to use this command"); } else { var file_path = com.bomberstudios.getFileFolder(), export_to_path = [doc askForUserInput:"Export to…" ofType:2 initialValue:file_path];

if (0 === export_to_path.indexOf("file://")) { export_to_path = export_to_path.substring(7); }

com.bomberstudios.export_all_artboards("png", export_to_path); }

bomberstudios commented 9 years ago

That's because you need to install all the files in my sketch-commands collection, not just copy & paste one of them : )

Use Sketch Toolbox to install 'Sketch Commands' and you'll be good to go!