2

I've about 0.1 million images in a directory with all kinds of extensions (gif, jpeg, png, tiff, etc).

Now I want to find out how many types (of extensions) are there in the current directory, possibly with total number of images associated with them using a terminal command, something like this:

some-command

png  - 11010
jpeg - 1134
jpg  - 145
tiff - 555

P.S: I do not want to count files with specific extension but rather want to count types of extensions with their associated files.

galoget
  • 2,943
  • 2
  • 20
  • 24
user_3pij
  • 135
  • 7
  • 4
    Possible duplicate of [Count total number of files in particular directory with specific extension](https://askubuntu.com/questions/454564/count-total-number-of-files-in-particular-directory-with-specific-extension) – galoget Jul 22 '19 at 04:17
  • Also possible duplicate of https://unix.stackexchange.com/questions/18506/recursive-statistics-on-file-types-in-directory – galoget Jul 22 '19 at 04:28

1 Answers1

1

The duplicate candidate (deep down) has a close answer. Here it is modified:

find . -maxdepth 1 -type f | sed 's/.*\.//' | sort | uniq -c
WinEunuuchs2Unix
  • 99,709
  • 34
  • 237
  • 401
  • One problem here. It's also finding files in sub-directories and I neither wish to count files in them nor want to move them because there's a lot of images in them. And I'll be grateful if you can tell what this command is doing so that I can exploit it in my way if I want to – user_3pij Jul 22 '19 at 04:33
  • I've added max depth to the find command. – WinEunuuchs2Unix Jul 22 '19 at 04:36