diff --git "a/docs/\343\200\212\351\233\205\346\200\235\350\200\203\350\257\225\345\256\230\346\226\271\346\214\207\345\215\227\343\200\213\357\274\210\347\254\2542\347\211\210\357\274\211tree.md" "b/docs/\343\200\212\351\233\205\346\200\235\350\200\203\350\257\225\345\256\230\346\226\271\346\214\207\345\215\227\343\200\213\357\274\210\347\254\2542\347\211\210\357\274\211tree.md" new file mode 100644 index 0000000..dd38cd6 --- /dev/null +++ "b/docs/\343\200\212\351\233\205\346\200\235\350\200\203\350\257\225\345\256\230\346\226\271\346\214\207\345\215\227\343\200\213\357\274\210\347\254\2542\347\211\210\357\274\211tree.md" @@ -0,0 +1,49 @@ +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/图书介绍.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/《雅思手册》相关视频/雅思考试机考写作部分操作指南.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/《雅思手册》相关视频/雅思考试机考听力部分操作指南.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/《雅思手册》相关视频/雅思视频通话口语考试流程.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/写作Task 2答题实例/05 Comments on Writing Samples.pdf +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/口语练习音频/02 IELTS Speaking Sample - Part 2.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/口语练习音频/03 IELTS Speaking Sample - Part 3.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/口语练习音频/01 IELTS Speaking Sample - Part 1.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/《雅思手册》相关视频/雅思考试机考操作系统简介.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/《雅思手册》相关视频/雅思考试机考阅读部分操作指南.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/口语练习音频/04 IELTS Speaking Sample - Full.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/01 Letters of the Alphabet.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/02 Groups of Letters.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/03 Spelling.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/04 Numbers.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/06 Test Practice - Section 1.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/05 Short-answer Questions.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/07 Matching Information.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/08 Multiple Choice.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/09 Test Practice - Section 2.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/11 Map 2.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/12 Sentence Completion.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/13 Test Practice - Section 3.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/14 Signposts.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/16 Flow Chart Completion.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/17 Summary Completion.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/模拟试题听力录音/01 Academic Test 1.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/模拟试题听力录音/02 Academic Test 2.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/模拟试题听力录音/03 Academic Test 3.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/模拟试题听力录音/04 Academic Test 4.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/01 Listening Band Descriptor.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/02 Reading Band Descriptor.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/03 Writing Band Descriptor 1 - Task Response.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/04 Writing Band Descriptor 2 - Coherence & Cohesion.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/05 Writing Band Descriptor 3 - Lexical Resource.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/06 Writing Band Descriptor 4 - Grammar.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/07 Speaking Band Descriptor 1 - Fluency & Coherence.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/08 Speaking Band Descriptor 2 - Lexical Resource.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/09 Speaking Band Descriptor 3 - Grammar.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:IELTS评分标准/10 Speaking Band Descriptor 4 - Pronunciation.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:口语考试实况录像/01 Speaking Sample 1.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:口语考试实况录像/02 Speaking Sample 2.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:口语考试实况录像/03 Speaking Sample 3.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:口语考试实况录像/04 Speaking Sample 4.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:口语考试实况录像/05 Comments on Speaking Samples.pdf +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/视频:雅思写作指导/07 Video - POWER Writing.mp4 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/15 Table Completion.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/10 Map 1.mp3 +/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)/听力练习音频/18 Test Practice - Section 4.mp3 diff --git a/server.js b/server.js index 627796b..b7d9651 100644 --- a/server.js +++ b/server.js @@ -1,24 +1,51 @@ -import fs, {stat} from 'node:fs'; +// import fs, {stat} from 'node:fs'; +import fs from 'node:fs'; import path from 'node:path'; +const rootFolder = '/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)'; +try { + let treeFilePath = rootFolder + `tree.md`; + if (!fs.existsSync(treeFilePath)) { + fs.writeFileSync(treeFilePath, ``, err => { + // init + }); + } else { + fs.writeFileSync(treeFilePath, ``, err => { + // clear + }); + } + // await fs.appendFile(rootFolder + `tree.md`, content); + // fs.writeFile(rootFolder + `tree.md`, content, err => { + // if (err) { + // console.error(err); + // } else { + // // file written successfully + // } + // }); +} catch (err) { + console.error(err); +} -const rootFolder = '/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)'; +// const isFile = fileName => { +// return fs.lstatSync(fileName).isFile() || false; +// }; +// const isFolder = fileName => { +// return fs.lstatSync(fileName).isDirectory() || false; +// }; -const isFile = fileName => { - return fs.lstatSync(fileName).isFile() || false; -}; -const isFolder = fileName => { - return fs.lstatSync(fileName).isDirectory() || false; -}; +const results = []; -try { +const treeGenerator = async (results = [], folderName = rootFolder) => { // 读取文件夹 - fs.readdirSync(rootFolder).map(fileName => { - console.log(`❓ fileName =`, fileName); - const pathName = path.join(rootFolder, fileName); - stat(pathName, (err, stats) => { + console.log(`🚀 folderName =`, folderName); + await fs.readdirSync(folderName).map(fileName => { + // console.log(`❓ fileName =`, fileName); + // path + const pathName = path.join(folderName, fileName); + // stat(pathName, (err, stats) => { + fs.stat(pathName, async (err, stats) => { // console.log(stats); // Stats { // dev: 16777220, @@ -40,7 +67,17 @@ try { // ctime: 2024-08-13T18:00:08.014Z, // birthtime: 2024-08-13T17:29:50.955Z // } - console.log(stats.isDirectory()); + // console.log(stats.isDirectory()); + if(stats.isDirectory()) { + console.log(`🗂️ folderName =`, fileName); + await treeGenerator(results, pathName) + } else { + console.log(`📂 fileName =`, fileName) + await fs.appendFile(rootFolder + `tree.md`, pathName + `\n`, err => { + // + }); + results.push(pathName); + } }); // if(isFolder(fileName)) { // console.log(`🗂️ folderName =`, fileName) @@ -54,18 +91,18 @@ try { // } // let temp = path.join(folderPath, fileName); }); +} + +try { + await treeGenerator(results, rootFolder); + console.log(`results =`, results); } catch (err) { console.error(`error ❌ =`, err); } -// try { -// if (!fs.existsSync(rootFolder)) { -// fs.mkdirSync(folderName); -// } -// } catch (err) { -// console.error(err); -// } + +