mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-12 22:14:49 +00:00
Update rename-to-lowercase.js
This commit is contained in:
1 parent
1eedc437a6
commit
f33e2f4f46
1 file changed
+7
-5
@@ -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();
|
||||
Reference in new issue
Block a user