Generated image
|| #resource

Count Files in Folder

Count the number of files in a folder using the terminal

The goal is to quickly count all the files that exist in a given folder (recursively).

find <path> -type f | wc -l

If you don't want to recurse down into all the sub-folders, the command can be tweaked to:

find <path> -type f -depth 1 | wc -l

The same logic can be used to count directories, simply replace the -type f with -type d. Or remove it entirely to count both.

find <path> -type d -depth 1 | wc -l

Related


Maybe try another one?

Reset Git Commit Author How to reset the author of one (or more) git commits
2022.09.05
What I Learnt When a Faster Algorithm Slowed Down My Code Don't fix what isn't broken
2021.09.28
Lowering the stakes of publishing Less perfection, more learning in public
2024.08.15