Finding all sub folders of a folder


I currently need to find every single subfolder of a folder I already found the path to. I also need to find the sub folders of those folders and any others as deep as possible, and find all files of a specific type inside. How do I approach this and what methods do I use?


Are you doing this in Atom, or in Electron?


Atom. Basically all I need is the method to find sub folders in a directory, and the method to find files in a directory. I’ve taken care of the rest.


Are you trying to do this cross platform? If not (eg. a personal script), and you’re on mac or linux, you can try ls -R which will recursively list all folders and files in a given directory (using the inbuilt child_process module).

Alternatively, there is the glob package.

Finally, you could use the inbuilt fs module to write a function that recursively calls itself in every directory it looks at.

See this Stack Exchange question.


This is a personal package but I’m on Windows, so. I’ll oil at the question later. I’d also rather use node js for it Thanks!


Look not oil