美文网首页
NodeJS rename 批量修改名字

NodeJS rename 批量修改名字

作者: ShoneSingLone | 来源:发表于2020-11-12 09:58 被阅读0次
import {
    promises as fs
} from "fs";
import path from "path";
(async () => {
    try {
        const res = await fs.readdir(path.resolve("./"));
        await Promise.all(
            res.filter(name => /.mp3$/.test(name))
            .map(async name => await fs.rename(name, `0${name}`))
        )
    } catch (error) {
        console.error(error)
    }
})();

相关文章

网友评论

      本文标题:NodeJS rename 批量修改名字

      本文链接:https://www.haomeiwen.com/subject/tmvubktx.html