find <parent dir> -type f -iname '*.flac' -printf '%h\n'|sort|uniq > flac.txt # this command finds all directories which contain flac files (replace "uniq" with "uniq -c" to have each line preceded with the count of files found) find <parent dir> -type f -iname '*.jpg' -printf '%h\n'|sort|uniq > jpg.txt # this command finds all directories which contain jpg files (replace "uniq" with "uniq -c" to have each line preceded with the count of files found) grep -f flac.txt jpg.txt # find common lines in both files diff flac.txt jpg.txt # find line differences in both files