Skip to content

Instantly share code, notes, and snippets.

@paranoidjk
Created August 28, 2016 08:34
Show Gist options
  • Save paranoidjk/bceef19314a6705315927cef6d6f63a0 to your computer and use it in GitHub Desktop.
Save paranoidjk/bceef19314a6705315927cef6d6f63a0 to your computer and use it in GitHub Desktop.
rename mutli images use nodejs
var fs = require('fs');
var path = require('path');
var dir = '/Users/jiangmu/Downloads/花花/';
fs.readdir(dir, function (err, files) {
if (err) {
console.log(err);
return;
}
var count = files.length;
var results = {};
files.forEach(function (file) {
var info = path.parse(file);
var rname = '[' + info.name + ']' +info.ext;
fs.rename(dir + file, dir + rname);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment