
const fs = require('fs');
const path = require('path');
function generateMarkdownForDirectory(dirPath, depth = 0, markdown = '') {
const files = fs.readdirSync(dirPath);
files.forEach((file) => {
const filePath = path.join(dirPath, file);
const stats = fs.statSync(filePath);
if (stats.isDirectory()) {
markdown += `${' '.repeat(depth)}- ${file}\n`;
markdown = generateMarkdownForDirectory(filePath, depth + 1, markdown);
} else {
markdown += `${' '.repeat(depth)}- [${file}](${filePath})\n`;
}
});
return markdown;
}
const directoryPath = 'D:\\frontedProject\\scriptcatList';
const markdownContent = generateMarkdownForDirectory(directoryPath);
fs.writeFileSync('scriptList.md', markdownContent);