Xjgou's blog Xjgou's blog
首页
  • 汇总

    • 文献汇总
  • 分类

    • 生物信息学
    • 单细胞空间组
    • 免疫学相关
    • scRNA-scATAC整合
  • 汇总

    • 生信工具汇总
  • 分类

    • 图像处理
    • 单细胞空间组
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
GitHub (opens new window)

Xjgou

生信小菜鸡
首页
  • 汇总

    • 文献汇总
  • 分类

    • 生物信息学
    • 单细胞空间组
    • 免疫学相关
    • scRNA-scATAC整合
  • 汇总

    • 生信工具汇总
  • 分类

    • 图像处理
    • 单细胞空间组
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
GitHub (opens new window)
  • 技术文档

  • GitHub技巧

  • Nodejs

    • nodejs递归读取所有文件
  • 博客搭建

  • 数据分析
  • Nodejs
xugaoyi
2019-12-26

nodejs递归读取所有文件

# nodejs递归读取所有文件


var fs = require('fs');
var path = require('path');
 
function readFileList(dir, filesList = []) {
    const files = fs.readdirSync(dir);
    console.log(files);
    files.forEach((item, index) => {
        var fullPath = path.join(dir, item);
        const stat = fs.statSync(fullPath);
        if (stat.isDirectory()) {      
            readFileList(path.join(dir, item), filesList);  //递归读取文件
        } else {                
            filesList.push(fullPath);                     
        }        
    });
    return filesList;
}
 
var filesList = [];
readFileList(__dirname,filesList);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
编辑 (opens new window)
GitHub加速下载项目的方法
解决百度无法收录搭建在GitHub上的个人博客的问题

← GitHub加速下载项目的方法 解决百度无法收录搭建在GitHub上的个人博客的问题→

最近更新
01
Benchmarking spatial clustering methods with spatially resolved transcriptomics data
03-05
02
Stress-induced red nucleus attenuation induces anxiety-like behavior and lymph node CCL5 secretion
02-20
03
scGPT toward building a foundation model for single-cell multi-omics using generative AI
06-19
更多文章>
Theme by Vdoing | Copyright © 2023-2025 xjgou | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式