How to fix macOS Finder not support semicolon symbol in filename error All In One
How to fix macOS Finder not support semicolon symbol in filename error All In One
macOS
Finder
不支持文件名中包含:
分号 bug ❌
error
semicolon
/ 分号punctuation marks
/ 标点符号
The name “01 项目基石:
前端脚手架工具探秘.mp4” can’t be used.
Try using a name with fewer characters, or with no punctuation
marks.
solution
// import * as pfs from "node:fs/promises";
import fs from 'node:fs';
import path from 'node:path';
const __dirname = path.resolve();
// const __filename = fileURLToPath(import.meta.url);
// console.log(`__dirname`, __dirname);
const folder = path.join(__dirname, '前端工程化精讲');
const files = fs.readdirSync(folder);
// console.log(`files`, files);
for (const file of files) {
// const filename = file.replaceAll(/(:)/g, ``).replace(/(/, `(`).replace(/)/, `)`).replace(`?`, ``);
const filename = file
.replace(/(\|\s)/g, ``)
.replace(/:/g, `_`)
// .replace(/:/g, `:`) // macOS Finder 不支持,文件名中包含 `:` 分号
.replace(/:/g, `_`)
.replace(/(/, `(`)
.replace(/)/, `)`)
.replace(/,/, `,`)
.replace(/(“|”)/g, `"`)
.replace(/、/g, `,`)
.replace(/(\/)/g, `_`)
.replace(`?`, ``);
fs.renameSync(`${folder}/${file}`, `${folder}/${filename}`, (err) => {
if(err) {
console.error(`rename ❌`, err);
}
console.log(`rename ✅`)
}
)
}
demos
refs
©xgqfrms 2012-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17704661.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
2022-09-15 在线文档 All In One
2022-09-15 Apple iPhone 官方原装保护壳港版与国行版区别 All In One
2021-09-15 Redux & React Hooks All In One
2020-09-15 C++ 0LL
2020-09-15 从长度为 M 的无序数组中,找出N个最小的数 All In One
2019-09-15 elm & redux
2019-09-15 约定优于配置