const fs = require("fs");
let path = '路径'
fs.readdir(path, function (err, files) {
files.forEach(function (filename, index) {
let oldPath = path + '/' + filename;
let newPath = oldPath.replace(/\Y[0-9]*\_/g, 'Y1_')
console.log(oldPath, '----------', newPath);
fs.rename(oldPath, newPath, function (err) {
if (!err) {
console.log(filename + '修改完成!')
}
})
})
})
网友评论