Skip to content

Commit

Permalink
feat: tree.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xgqfrms committed Aug 20, 2024
1 parent 9b75e37 commit aeaa43f
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 21 deletions.
49 changes: 49 additions & 0 deletions docs/《雅思考试官方指南》(第2版)tree.md
Original file line number Diff line number Diff line change
@@ -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
79 changes: 58 additions & 21 deletions server.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)
Expand All @@ -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);
// }





Expand Down

0 comments on commit aeaa43f

Please sign in to comment.