Created
August 28, 2016 08:34
-
-
Save paranoidjk/bceef19314a6705315927cef6d6f63a0 to your computer and use it in GitHub Desktop.
rename mutli images use nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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