-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
baichun
committed
May 6, 2019
1 parent
10f9f95
commit 184eec7
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,6 @@ src | |
| | ||
└───util(工具函数) | ||
| | ||
└───deepClone(深拷贝) | ||
└───deepClone(深拷贝) | ||
| | ||
└───renameFile(批量修改文件名) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var fs = require('fs'); | ||
|
||
var PATH = './src/components/listNav/img'; // 目录 | ||
|
||
// 遍历目录得到文件信息 | ||
function walk(path, callback) { | ||
var files = fs.readdirSync(path); | ||
|
||
files.forEach(function(file){ | ||
if (fs.statSync(path + '/' + file).isFile()) { | ||
callback(path, file); | ||
} | ||
}); | ||
} | ||
|
||
// 修改文件名称 | ||
function rename (oldPath, newPath) { | ||
fs.rename(oldPath, newPath, function(err) { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
} | ||
|
||
// 运行 | ||
walk(PATH, function (path, fileName) { | ||
var oldPath = path + '/' + fileName, // 源文件路径 | ||
newPath = path + '/'+ fileName.replace(/icon-/, 'icon_'); // 新路径 | ||
|
||
rename(oldPath, newPath); | ||
}); | ||
|
||
//copy: https://www.jianshu.com/p/4d823a522ccc |
Empty file.