Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fearphage/780265 to your computer and use it in GitHub Desktop.
var sys = require("sys"),
fs = require("fs");
function processImageDir(path, outFilename, cb) {
fs.readdir(path, function(err, files) {
fs.writeFile(__dirname + '/' + outFilename, JSON.stringify({
images: files.filter(function(name) { return /(?:png|jpe?g|gif)$/i.test(name); })
}), function(err) {
if (err) throw err;
cb && cb("Sweet.");
});
});
}
processImageDir('/path/to/your/images/dir', "preload-images.json", function(message) {
console.log(message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment