155
64
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?
10I do not understand why this question is off-topic (after 3 years). I do not ask for a specific software (i reworded my question to underline this). I just aks for a solution. – Martin – 2014-12-22T10:13:54.123
2I don't understand why 26 people think that boehj *nix-related comment above "adds something useful to the post". This question is tagged
windows
, 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 – 2015-09-08T14:47:04.1832@Aacini useful for *nix people who come here from google. – jingyu9575 – 2015-11-14T14:46:10.377
Moved to http://softwarerecs.stackexchange.com/questions/36519/determine-file-type-from-its-content-not-trusting-the-extension
– Nicolas Raoul – 2016-09-28T06:48:00.480@Aacini Also, Windows 10 now supports bash, so
file
is now a valid answer to this question (although I haven't tested it). – ThatMatthew – 2017-08-15T13:30:02.22737For those interested the
file
command does this on *nix machines. – boehj – 2011-04-24T12:37:22.497