File extension statistics ?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

File extension statistics ?

Post by Vilsen »

Is it possible to write something in the terminal in some way

so that you get a list of all different file extensions that a hard drive contains

and how many of each kind ??

Example of possible result:

*.jpg 123456 files total

*.gif 54321 files total

and so on...
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: File extension statistics ?

Post by Flemur »

Code: Select all

$ find -iname "*.jpg" |  wc
  15101   15147  696695
15101 is the number of .jpg files. Dunno what the others are, try

Code: Select all

man wc
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
MrEen
Level 23
Level 23
Posts: 18343
Joined: Mon Jun 12, 2017 8:39 pm

Re: File extension statistics ?

Post by MrEen »

Flemur wrote: Sun Feb 17, 2019 2:49 pm

Code: Select all

$ find -iname "*.jpg" |  wc
  15101   15147  696695
15101 is the number of .jpg files. Dunno what the others are, try

Code: Select all

man wc
My understanding:
15101 is the number of lines (the total number of matching filenames)
15147 is the number of words (you have a few jpegs with spaces in their names)
696695 is the number of characters (bytes) returned
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: File extension statistics ?

Post by Flemur »

MrEen wrote: Sun Feb 17, 2019 3:07 pm My understanding:
15101 is the number of lines (the total number of matching filenames)
15147 is the number of words (you have a few jpegs with spaces in their names)
696695 is the number of characters (bytes) returned
Sounds right - I never knowingly use delimiters in file names, so got curious and it turned out they were in a "Deep Art Effects" directory copied from a phone.

Edit: OP, notes on this comamnd:
find -iname "*.jpg" | wc

"iname" = find by name, i = ignore case (finds JPG, jPG, etc)
"*.jpg" = files which end in .jpg. Use the quotes so "*.jpg" doesn't get expanded, e.g. if you ran

Code: Select all

find -iname *.jpg 
in a directory with fred.jpg, it would expand to:

Code: Select all

find -iname fred.jpg
and find files named fred.jpg.

To see the difference, go to a directory with some jpg files and enter

Code: Select all

echo *.jpg
echo "*.jpg"
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
xenopeek
Level 25
Level 25
Posts: 29611
Joined: Wed Jul 06, 2011 3:58 am

Re: File extension statistics ?

Post by xenopeek »

File extensions don't mean much in Linux, but sure.

Perhaps a command like this:
find . -type f -printf '%f\n' | grep '^[^.].*\.' | awk -F. '{print $NF}' | sort | uniq -c | sort -n

This finds all files in the current directory and prints their name, ignores any files that start with a dot, prints the extensions of the remaining files, sorts those extensions, counts each unique extensions and finally sorts on the results such that the extensions are shown from lease frequent to most frequent.

Running that command from your home directory shouldn't take seconds. Running it on your entire filesystem (from / directory) will take a bit.
Image
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

[SOLVED]Re: File extension statistics ?

Post by Vilsen »

I am deeply impressed! I come closer and closer to a "salvation"
and I realize with fear that so many others on this earth have been so misled by this troll that Pyttemjuk sold into us.

Perhaps one can now go one step to find a program or otherwise use the time / date

information contained in the EXIF data contained in each image (JPEG) (RAW)

and use this date to sort images into Chronological order ? Someone who knows something about this ???
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

[SOLVED] Re: File extension statistics ?

Post by Vilsen »

[SOLVED]
Locked

Return to “Beginner Questions”