Finding images on bash regardless of extension

chris Source

I am looking a Bash command that will allow me to identify all images in a directory regardless of file extension. For example if a photo was given a .doc extension I want to be able to identify it using a script.

So far I have the below but it is only returning images with the typical file extensions.

find . -type f -exec file {} \; | grep -i -o -E '^.+: \w+ image' 
linuxbashunix

Answers

answered 4 months ago Mark Setchell #1

I would go with this:

file --mime-type * | grep "image/"

Sample Output

gif.doc:             image/gif
jpg.doc:             image/jpeg
png.doc:             image/png
result.doc:          image/tiff

comments powered by Disqus