查找具有通配符匹配的文件 [英] find file with wild card matching

查看:100
本文介绍了查找具有通配符匹配的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在node.js中,我是否可以列出具有通配符匹配的文件,例如

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

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

我没有从中找到有关通配符匹配的信息. fs文档.

推荐答案

Node核心未涵盖此内容.您可以查看此模块以了解所需内容. npmjs.org还是查找各种模块的好资源.

This is not covered by Node core. You can check out this module for what you are after. npmjs.org is also a great resource for finding various modules.

var glob = require("glob")

// options is optional
glob("**/*.js", options, function (er, files) {
  // files is an array of filenames.
  // If the `nonull` option is set, and nothing
  // was found, then files is ["**/*.js"]
  // er is an error object or null.
})

这篇关于查找具有通配符匹配的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆