Identify Windows File Types

FileType is a Windows command line utility that reads the first 20 bytes of a file and attempts to identify what kind of file it is, given a seed file.

Usage:
   FILETYPE.EXE -i [-r] [-o ] [-v] [-?]

     -i - Inspect a single file or all files in a directory
     -r - Rename the file with the correct extension (-o ignored)
     -o - Output path for file copies (creates if not exist)
     -v - Verbose output
     -? - This help text

Examples:
  filetype -i c:\windows  <-- Report on file types
  filetype -i c:\windows -r  <-- Rename files to identified types
  filetype -i c:\windows -o c:\win  <-- Copy files to c:\win and rename to found file types

You can download FileType from here.


Use the filehdr util to dump the hex header of a file to add your own entries to the seed file

Bugs:
Yes, there are bugs. I have no plans on fixing them either.
- If you specify the root of a directory with the backslach in the -i param (-i c:\ instead of -i c:), you will get a 'Cannot open c:\' error
- It will not recurse directories
- Yes, you can overflow the params. VC6 didn't mind a realloc of smaller sizes, but VC7 complained. I took the lazy way and used char arrays instead
- If you put duplicate entries in the filetypes.dat file and have the util rename the files, if it hits the duplicate entry, it will complain that it could not find the file since it has already been renamed to something else
- Some files use the same header (ex. Word docs, .MSI installer files and Reflection R2W files use the same, as do .EXE and .DLL's). Remember this as it idents files.
- Don't ask for the source code. It is a mess. It started out very nice, be the realloc problem forced me to kludge it together