find file with wild card matching

后端 未结 5 1695
滥情空心
滥情空心 2020-12-08 18:31

In node.js, can I list files with wild card matching like

fs.readdirSync(\'C:/tmp/*.csv\')?

I did not find the information on wild card ma

5条回答
  •  遥遥无期
    2020-12-08 18:46

    Just in case you want to search files by regex (for complex matches), then consider using file-regex, which supports recursive search and concurrency control (for faster results).

    Sample usage

    import FindFiles from 'file-regex'
    
    // This will find all the files with extension .js
    // in the given directory
    const result = await FindFiles(__dirname, /\.js$/);
    console.log(result)
    

提交回复
热议问题