Artificial intelligent assistant

Finding a file type assuming wrong extension I have an image archive I keep up. Sometimes, the sites I pull them from reformat the file while keeping the extension the same, most often making PNG images into JPG's that are still named ".png". Is there a way to discover when this has happened and fix it automatically? When on Windows, I used IrfanView for this, but that needs a Wine wrapper.

You can use `file` command:


$ file file.png
file.png: PNG image data, 734 x 73, 8-bit/color RGB, non-interlaced

$ mv file.png file.txt
$ file file.txt
file.txt: PNG image data, 734 x 73, 8-bit/color RGB, non-interlaced


The `file` does some tests on file to determine its type. Probably the most important test is comparing a magic number (string in a file header) with pre-defined list.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 539be1020f6d79083e4fe87924ab4463