1

I am exploring the filemanip library to search for markdown files in a path including subfolders

import System.FilePath.Find

find always (fileType ==? RegularFile &&? extension ==? ".md") "a/path/"

is there any way to specify a folder name or pattern into which it should not recurse

Markus1189
  • 2,829
  • 1
  • 23
  • 32
greole
  • 4,523
  • 5
  • 29
  • 49
  • 1
    yes with the first parameter of `find` (you choose `always` here but you can do basically the same as with the file - they are named differently but they are really both [FindClause Bool](https://hackage.haskell.org/package/filemanip-0.3.6.3/docs/System-FilePath-Find.html#t:FindClause) - just use `directory` there to get the names) – Random Dev Aug 13 '15 at 16:30

1 Answers1

4

Looking at the documentation we can see that find takes as first argument a RecursionPredicate which in turn is just FindClause Bool.

Based on this we can see that we have to pass in a custom RecursionPredicate to find other than always. One example is to ignore .git directories:

notGit :: FindClause Bool -- or via type alias also a RecursionPredicate
notGit = directory /=? ".git"

We then just use our new recursion predicate with find:

find notGit (fileType ==? RegularFile &&? extension ==? ".md") path

Note also the special combinators for predicates to e.g. compose a notSvn predicate with our notGit predicate via (||?) to get a predicate that enters neither directories.

Markus1189
  • 2,829
  • 1
  • 23
  • 32