thecodrr / fdir

⚡ The fastest directory crawler & globbing library for NodeJS. Crawls 1m files in < 1s

Home Page:https://thecodrr.github.io/fdir/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to search for a folder by its name and return the folder path?

mark134340 opened this issue · comments

How to search for a folder by its name and return the folder path instead of returning all the parent directories?

const files = new fdir()
                    .withBasePath()
                    // .withDirs()
                    .withFullPaths()
                    // .glob("F:/CGLibrary/**/*Video*")
                    .filter((path) => path.indexOf("Video") != -1)
                    .crawl("F:/")
                    .sync();
                
                console.log(files);

Single folder search is not possible yet. I am working on adding it though. Perhaps in the next version?

This should now be possible as:

const files = new fdir()
  .onlyDirs()
  .filter((path) => {
    return path.endsWith("/composition/examples/src");
  })
  .crawl("node_modules")
  .sync();

console.log(files[0]);