Quantcast
Channel: Count number of files with specific extension(s) for each subdirectory - Ask Ubuntu
Viewing all articles
Browse latest Browse all 4

Count number of files with specific extension(s) for each subdirectory

$
0
0

Source: Any directory tree with any number and type of files. Q: How many .jpg or .jpg and .png (for example) are in each subdirectory?

How can I limit the code below for files with 1 or more specific extension(s)? Having trouble inserting the -type f -name "*.jpg*", for example.

for DIR in $(find . -maxdepth 99 -type d)do    printf "%10d\t%s\n" $(find ${DIR}|wc -l) "${DIR}" done

Desired output:

118   ./aaa 73   ./aaa/bbb 16   ./aaa/bbb/ccc

If more than one file types are counted, then their combined total number in each subdirectories should be displayed.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images