2018-11-23

MacOS - How to list the number of files on sub-directories, recursively (command line)

find . -type d -print0 | while read -d '' -r dir; do
    files=("$dir"/*)
    printf "%5d file count for directory %s\n" "${#files[@]}" "$dir"
done

Credits: https://stackoverflow.com/questions/15216370/how-to-count-number-of-files-in-each-directory

No comments:

Post a Comment