require lowercase file names

This commit is contained in:
William Harrison
2024-11-09 20:42:50 +08:00
parent f4e60cab35
commit 1eedc437a6
4 changed files with 43 additions and 9 deletions
+30
View File
@@ -0,0 +1,30 @@
const fs = require("fs");
const path = require("path");
const directoryPath = path.join(__dirname, "../domains");
(async () => {
// Read the files in the 'domains' directory
fs.readdirSync(directoryPath, (err, files) => {
if (err) {
console.error("Error reading directory:", err);
return;
}
files.forEach(async (file) => {
const oldPath = path.join(directoryPath, file);
const newPath = path.join(directoryPath, file.toLowerCase());
// Only rename if the file name is not already in lowercase
if (oldPath !== newPath) {
fs.renameSync(oldPath, newPath, (err) => {
if (err) {
console.error("Error renaming file:", err);
} else {
console.log(`Renamed: ${file} -> ${file.toLowerCase()}`);
}
});
}
});
});
})();