In addition to the file
command, you can also use ImageMagick. The following will show the type of all files in the current directory:
find -type f -depth 0 -print0 | xargs -0 identify
The identify
command will print out something like this for various file types:
text.txt[8] TXT 612x792 612x792+0+0 16-bit DirectClass 694B 0.320u 0:00.330
php.jpg[31] JPEG 1280x1024 1280x1024+0+0 8-bit DirectClass 195KB 0.000u 0:00.000
Animated GIF files will print more information (this is a 21-frame GIF):
adhd.gif[0] GIF 211x200 211x200+0+0 8-bit PseudoClass 256c 233KB 0.000u 0:00.029
adhd.gif[1] GIF 168x130 211x200+22+22 8-bit PseudoClass 256c 233KB 0.000u 0:00.029
adhd.gif[2] GIF 168x130 211x200+22+22 8-bit PseudoClass 256c 233KB 0.000u 0:00.029
...
adhd.gif[18] GIF 168x130 211x200+22+22 8-bit PseudoClass 256c 233KB 0.000u 0:00.000
adhd.gif[19] GIF 168x130 211x200+22+22 8-bit PseudoClass 256c 233KB 0.000u 0:00.000
adhd.gif[20] GIF 168x130 211x200+22+22 8-bit PseudoClass 256c 233KB 0.000u 0:00.000
You can then use awk
or similar tools to decide what to do with them.