// 导入fs 模块
const fs = require('fs')
// 读取 code 文件夹
const files = fs.readdirSync('../01_初始js')
files.forEach(item => {
// 拆分文件名
let data = item.split('-')
let [num, name] = data
// 判断
if (Number(num) < 10) {
num = '0' + num
}
let newName = num + '-' + name
console.log(newName)
})
07-03
210
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-18
3万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-02
1257
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-31
639
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)