const fs = require("fs"); const path = require("path"); function removeZoneIdentifier(dir) { fs.readdirSync(dir).forEach((file) => { const filePath = path.join(dir, file); if (fs.lstatSync(filePath).isDirectory()) { removeZoneIdentifier(filePath); // 递归处理子目录 } else { // const newFilePath = filePath.replace(/\.Zone\.Identifier$/, ""); // if (newFilePath !== filePath) { // console.log(`removing ${filePath}`); // } if (filePath.search(/:Zone\.Identifier$/) > -1) { fs.unlinkSync(filePath); // 删除文件而不是重命名 console.log("removing ", filePath); } if (filePath.search(/.bak$/) > -1) { fs.unlinkSync(filePath); // 删除文件而不是重命名 console.log("removing ", filePath); } if (filePath.search(/.del$/) > -1) { fs.unlinkSync(filePath); // 删除文件而不是重命名 console.log("removing ", filePath); } } }); } removeZoneIdentifier(process.cwd()); console.log("done");