From f33e2f4f469b3dd69e4a713796936f51f55fb1bf Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Sat, 9 Nov 2024 20:43:57 +0800 Subject: [PATCH] Update rename-to-lowercase.js --- scripts/rename-to-lowercase.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/rename-to-lowercase.js b/scripts/rename-to-lowercase.js index 4aa8223d7..4dc932ee0 100644 --- a/scripts/rename-to-lowercase.js +++ b/scripts/rename-to-lowercase.js @@ -3,21 +3,21 @@ const path = require("path"); const directoryPath = path.join(__dirname, "../domains"); -(async () => { +function renameFilesToLowercase() { // Read the files in the 'domains' directory - fs.readdirSync(directoryPath, (err, files) => { + fs.readdir(directoryPath, (err, files) => { if (err) { console.error("Error reading directory:", err); return; } - files.forEach(async (file) => { + files.forEach((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) => { + fs.rename(oldPath, newPath, (err) => { if (err) { console.error("Error renaming file:", err); } else { @@ -27,4 +27,6 @@ const directoryPath = path.join(__dirname, "../domains"); } }); }); -})(); +} + +renameFilesToLowercase();