82

How to count all files inside a folder, its subfolder and all . The count should not include folder count.

I want to do it in MAC

Peter
  • 2,679
  • 3
  • 23
  • 49

2 Answers2

190

find . -type f | wc -l will recursively list all the files (-type f restricts to only files) in the current directory (replace . with your path). The output of this is piped into wc -l which will count the number of lines.

Jeff Foster
  • 42,070
  • 11
  • 81
  • 103
29

Find all files under myfolder and count them using wc. This works on linux:

find myfolder -type f | wc -l

perreal
  • 90,214
  • 20
  • 145
  • 172