I sometimes get files from my clients that have the wrong file extension. For example, the name is image.jpg but the file is actually a TIFF image. In many cases I can clarify it by opening the file in a text editor, looking at the first few bytes, then deducing which file type it is.
This works for me with JPEG, TIFF, GIF and PDF files. However there are many more file types out there.
Is it possible to automate identification of the correct file type by analyzing the containing data?


filecommand does this on *nix machines. – boehj Apr 24 '11 at 12:37windows, but the comment imply: "You can't do that on Windows, you must use nix instead". So? The comment is directed "for those interested". In what? Change computer?:(– Aacini Sep 08 '15 at 14:47fileis now a valid answer to this question (although I haven't tested it). – ThatMatthew Aug 15 '17 at 13:30