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?

Docker: Use Container Env in Docker Exec How to use the container environment in a Docker Exec command
2021.05.09
Count Files in Folder Count the number of files in a folder using the terminal
2022.10.03
Nextcloud: Mount as a Folder How to mount your Nextcloud account as a regular folder on Linux
2021.05.02