Created
February 28, 2016 13:04
-
-
Save deptno/0980dba3549f38dcd450 to your computer and use it in GitHub Desktop.
change files name
This file contains 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
const fs = require('fs'); | |
var dirs = fs.readdirSync(__dirname); | |
var regexp = /[0-9-]+-(.+)/; | |
dirs.forEach(function(file) { | |
var stat = fs.lstatSync(file); | |
if (stat && !stat.isDirectory()) { | |
if (regexp.test(file)) { | |
var newName = file.replace(regexp, "$1"); | |
console.log(`filename change ${file} to ${newName}`); | |
fs.renameSync(file, newName); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment