how to get total file size of all images that fullfill exiftool critera

Started by timitalia, October 26, 2018, 10:05:01 AM

Previous topic - Next topic

timitalia

I'd like to retrieve the total file size of all images that fullfill a certain critera (recursively whithin a directory)

For example if  I execute the following bash command

find ~/SomeDirectory -type f -name '*.JPG' -exec du -ch {} + | grep total$

I get the total file size of all files with the extension JPG (nicely human readable like e.g. "50.2G   total")

Now I would like to get the same result but using exiftool "if expressions" like

exiftool -r -T -if '$FileType eq "JPEG" ~/SomeDirectory -FilePath

Of course, this only lists me all the FilePaths. So how would I get the total file size for all these files, like above?

Working solutions are appreciated, thank you in advance!

Phil Harvey

This should do it:

exiftool -r -if '$FileType eq "JPEG"' ~/SomeDirectory -filesize# -s3 -q | awk '{ total+=$1 }; END { printf "%.0f\n", total }'

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

timitalia

What an awsome response time, thank you very much, thats exactly it! Love your tool. Cheers!