Using Node.js to rename set of images
Today I had to rename a bunch of image files to the same names, but in lower case. Here is how I did it.
Let's say that the folder is called players. The Node.js script looks like that:
var glob = require("glob"), path = require("path"), fs = require("fs");
glob(__dirname + "/players/**/*.*", function(err, files) { var processed = 0; files.forEach(function(file) { var dir = path.dirname(file); var filename = path.basename(file); fs.renameSync(file, dir + "/" + filename.toLowerCase()); processed++; }); console.log(processed + " files processed"); });
And here is the package.json file needed:
{ "name": "RenameAllToLowerCase", "description": "", "version": "0.0.1", "dependencies": { "glob": "*" }, "main": "index.js" }