首页 > 解决方案 > Matching all files without an extension, excluding folders [Minimatch]

问题描述

Using minimatch I can get all the files with the following pattern !*.* but it also matches folder and no longer matches correctly within folders.

I'm testing the patterns here => http://pthrasher.github.io/minimatch-test/

With the following data

404
404.html
index
index.html
apples/
apples/a
apples/a.html
apples/b
apples/b.html
oranges/
oranges/c
oranges/c.html
oranges/d
oranges/d.html

Expected outcome would be

404
index
apples/a
apples/b
oranges/c
oranges/d

标签: minimatch

解决方案


My current solution was to use a few patterns:

  • one for the "index"
  • one for the "404"
  • one for any files without extensions within folders "*/!(*.*)"

推荐阅读