Skip to content

Commit

Permalink
test-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Avdhesh-Varshney committed Sep 21, 2024
1 parent 8bebb44 commit f929831
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 1 deletion.
1 change: 0 additions & 1 deletion projects/vanilla-js/advanced/Audio-Analyzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=for-the-badge&logo=html5&logoColor=white)
![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=for-the-badge&logo=css3&logoColor=white)
![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)
<!-- ![Redux](https://img.shields.io/badge/redux-%23593d88.svg?style=for-the-badge&logo=redux&logoColor=white) -->
<!-- ![TailwindCSS](https://img.shields.io/badge/tailwindcss-%2338B2AC.svg?style=for-the-badge&logo=tailwind-css&logoColor=white) -->
<!-- ![Web3.js](https://img.shields.io/badge/web3.js-F16822?style=for-the-badge&logo=web3.js&logoColor=white) -->
<!-- ![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB) -->
Expand Down
38 changes: 38 additions & 0 deletions renameFolders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import fs from 'fs';
import path from 'path';

const baseDir = './projects/'; // Adjust this to your base directory

const toValidProjectName = (name) => {
return name
.toLowerCase()
.replace(/[^a-z0-9._-]/g, '-')
.replace(/-{2,}/g, '-')
.replace(/^-+|-+$/g, '');
};

const renameDirectories = (dir) => {
fs.readdir(dir, (err, files) => {
if (err) throw err;

files.forEach((file) => {
const currentPath = path.join(dir, file);
const newName = toValidProjectName(file);
const newPath = path.join(dir, newName);

if (fs.statSync(currentPath).isDirectory()) {
if (newPath !== currentPath) {
fs.rename(currentPath, newPath, (err) => {
if (err) throw err;
console.log(`Renamed: ${currentPath} to ${newPath}`);
});
}
// Recursively rename inside subdirectories
renameDirectories(newPath);
}
});
});
};

// Start renaming from the base directory
renameDirectories(baseDir);

0 comments on commit f929831

Please sign in to comment.