Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

find file with wild card matching

find file with wild card matching

Problem

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 matching from the fs documention.

Problem Courtesy of: ahala

Solution

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.

Usage

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.
})
Solution courtesy of: Morgan ARR Allen

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

find file with wild card matching

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×