UnFOUNDchk - Recover data from .CHK files

17.06.2023, 21:41 - Autor: Mark B.
As mentiond it's a ver bad idea to run chkdsk on a drive when you plan to recover data! Good old HDDs would at least allow you to recover deleted data but this would be not possible on moden SSDs.

Another function of chkdsk cause the tool to move and rename file into FOUND.### folders. Hereby stand ### for a numerical value. This folders are then full with files named FILE####.CHK which are very often fully functional files. So we loose often the context because filenames and folder-structures are often very important - e.g. Analysis marketing data 2023-04 v3.xlsx would not just tell us what is the content of the file but also what version of the file we are dealing with and in case of D:\Patients\2023\Joe_Black\X_Ray\IMG03765.PNG the folder structure would tell us to which patient the x-ray images belong!

Loosing that information may render data even unusable in extreme cases...

This is the reason why I strongly advice againce chkdsk! In case your data got damaged by chkdsk you can use the following free tool to revert the .CHK files back into the original formats.

Download Source       Download Windows EXE

Source:

s = set()

exts = {
    'application/CDFV2' : "cdf",
    'x-world/x-3dmf' : '.3dm',
    'application/x-authorware-bin' : '.aab',
    'application/x-authorware-map' : '.aam',
    'application/x-authorware-seg' : '.aas',
    'text/vnd.abc' : '.abc',
    'video/animaflex' : '.afl',
    'application/postscript' : '.ps',
    'audio/aiff' : '.aif',
    'audio/x-aiff' : '.aif',
    'application/x-aim' : '.aim',
    'text/x-audiosoft-intra' : '.aip',
    'application/x-navi-animation' : '.ani',
    'application/x-nokia-9000-communicator-add-on-software' : '.aos',
    'application/mime' : '.aps',
    'application/arj' : '.arj',
    'image/x-jg' : '.art',
    'video/x-ms-asf' : '.asf',
    'text/x-asm' : '.asm',
    'text/asp' : '.asp',
    'application/x-mplayer2' : '.asx',
    'video/x-ms-asf' : '.asx',
    'video/x-ms-asf-plugin' : '.asx',
    'audio/basic' : '.au',
    'audio/x-au' : '.au',
    'application/x-troff-msvideo' : '.avi',
    'video/avi' : '.avi',
    'video/msvideo' : '.avi',
    'video/x-msvideo' : '.avi',
    'video/avs-video' : '.avs',
    'application/x-bcpio' : '.bcpio',
    'application/mac-binary' : '.bin',
    'application/macbinary' : '.bin',
    'application/octet-stream' : '.bin',
    'application/x-binary' : '.bin',
    'application/x-macbinary' : '.bin',
    'image/bmp' : '.bmp',
    'image/x-windows-bmp' : '.bmp',
    'application/book' : '.book',
    'application/x-bsh' : '.bsh',
    'application/x-bzip' : '.bz',
    'application/x-bzip2' : '.bz2',
    'text/x-c' : '.c',
    'application/vnd.ms-pki.seccat' : '.cat',
    'application/clariscad' : '.ccad',
    'application/x-cocoa' : '.cco',
    'application/cdf' : '.cdf',
    'application/x-cdf' : '.cdf',
    'application/x-netcdf' : '.cdf',
    'application/pkix-cert' : '.cer',
    'application/x-x509-ca-cert' : '.cer',
    'application/x-chat' : '.chat',
    'application/java' : '.class',
    'application/java-byte-code' : '.class',
    'application/x-java-class' : '.class',
    'application/x-cpio' : '.cpio',
    'application/mac-compactpro' : '.cpt',
    'application/x-compactpro' : '.cpt',
    'application/x-cpt' : '.cpt',
    'application/pkcs-crl' : '.crl',
    'application/pkix-crl' : '.crl',
    'application/pkix-cert' : '.crt',
    'application/x-x509-ca-cert' : '.crt',
    'application/x-x509-user-cert' : '.crt',
    'application/x-csh' : '.csh',
    'text/x-script.csh' : '.csh',
    'application/x-pointplus' : '.css',
    'text/css' : '.css',
    'application/x-director' : '.dcr',
    'application/x-deepv' : '.deepv',
    'application/x-x509-ca-cert' : '.der',
    'video/x-dv' : '.dif',
    'application/x-director' : '.dir',
    'video/dl' : '.dl',
    'video/x-dl' : '.dl',
    'application/msword' : '.docx',
    'application/commonground' : '.dp',
    'application/drafting' : '.drw',
    'video/x-dv' : '.dv',
    'application/x-dvi' : '.dvi',
    'drawing/x-dwf (old)' : '.dwf',
    'model/vnd.dwf' : '.dwf',
    'application/acad' : '.dwg',
    'image/vnd.dwg' : '.dwg',
    'image/x-dwg' : '.dwg',
    'application/dxf' : '.dxf',
    'image/vnd.dwg' : '.dxf',
    'image/x-dwg' : '.dxf',
    'application/x-director' : '.dxr',
    'text/x-script.elisp' : '.el',
    'application/x-bytecode.elisp (compiled elisp)' : '.elc',
    'application/x-elc' : '.elc',
    'application/x-envoy' : '.env',
    'application/postscript' : '.eps',
    'application/x-esrehber' : '.es',
    'text/x-setext' : '.etx',
    'application/envoy' : '.evy',
    'application/x-envoy' : '.evy',
    'text/x-fortran' : '.f',
    'application/vnd.fdf' : '.fdf',
    'application/fractals' : '.fif',
    'image/fif' : '.fif',
    'video/fli' : '.fli',
    'video/x-fli' : '.fli',
    'image/florian' : '.flo',
    'text/vnd.fmi.flexstor' : '.flx',
    'video/x-atomic3d-feature' : '.fmf',
    'text/x-fortran' : '.for',
    'image/vnd.fpx' : '.fpx',
    'image/vnd.net-fpx' : '.fpx',
    'application/freeloader' : '.frl',
    'audio/make' : '.funk',
    'image/g3fax' : '.g3',
    'image/gif' : '.gif',
    'video/gl' : '.gl',
    'video/x-gl' : '.gl',
    'audio/x-gsm' : '.gsd',
    'audio/x-gsm' : '.gsm',
    'application/x-gsp' : '.gsp',
    'application/x-gss' : '.gss',
    'application/x-gtar' : '.gtar',
    'application/x-compressed' : '.gz',
    'application/x-gzip' : '.gz',
    'application/x-gzip' : '.gzip',
    'multipart/x-gzip' : '.gzip',
    'text/x-h' : '.h',
    'application/x-hdf' : '.hdf',
    'application/x-helpfile' : '.help',
    'application/vnd.hp-hpgl' : '.hgl',
    'text/x-h' : '.hh',
    'text/x-script' : '.hlb',
    'application/hlp' : '.hlp',
    'application/x-helpfile' : '.hlp',
    'application/x-winhelp' : '.hlp',
    'application/vnd.hp-hpgl' : '.hpg',
    'application/vnd.hp-hpgl' : '.hpgl',
    'application/binhex' : '.hqx',
    'application/binhex4' : '.hqx',
    'application/mac-binhex' : '.hqx',
    'application/mac-binhex40' : '.hqx',
    'application/x-binhex40' : '.hqx',
    'application/x-mac-binhex40' : '.hqx',
    'application/hta' : '.hta',
    'text/x-component' : '.htc',
    'text/html' : '.html',
    'text/webviewhtml' : '.htt',
    'x-conference/x-cooltalk' : '.ice',
    'image/x-icon' : '.ico',
    'image/ief' : '.ief',
    'application/iges' : '.iges',
    'model/iges' : '.iges',
    'application/x-ima' : '.ima',
    'application/x-httpd-imap' : '.imap',
    'application/inf' : '.inf',
    'application/x-internett-signup' : '.ins',
    'application/x-ip2' : '.ip',
    'video/x-isvideo' : '.isu',
    'audio/it' : '.it',
    'application/x-inventor' : '.iv',
    'i-world/i-vrml' : '.ivr',
    'application/x-livescreen' : '.ivy',
    'audio/x-jam' : '.jam',
    'text/x-java-source' : '.java',
    'application/x-java-commerce' : '.jcm',
    'image/jpeg' : '.jpg',
    'image/pjpeg' : '.jpg',
    'image/x-jps' : '.jps',
    'application/x-javascript' : '.js',
    'application/javascript' : '.js',
    'application/ecmascript' : '.js',
    'text/javascript' : '.js',
    'text/ecmascript' : '.js',
    'image/jutvision' : '.jut',
    'audio/midi' : '.kar',
    'music/x-karaoke' : '.kar',
    'application/x-ksh' : '.ksh',
    'text/x-script.ksh' : '.ksh',
    'audio/nspaudio' : '.la',
    'audio/x-nspaudio' : '.la',
    'audio/x-liveaudio' : '.lam',
    'application/x-latex' : '.latex',
    'application/lha' : '.lha',
    'application/x-lha' : '.lha',
    'audio/nspaudio' : '.lma',
    'audio/x-nspaudio' : '.lma',
    'application/x-lisp' : '.lsp',
    'text/x-script.lisp' : '.lsp',
    'text/x-la-asf' : '.lsx',
    'application/x-latex' : '.ltx',
    'application/x-lzh' : '.lzh',
    'application/lzx' : '.lzx',
    'application/x-lzx' : '.lzx',
    'text/x-m' : '.m',
    'video/mpeg' : '.m1v',
    'audio/mpeg' : '.m2a',
    'video/mpeg' : '.m2v',
    'audio/x-mpequrl' : '.m3u',
    'application/x-troff-man' : '.man',
    'application/x-navimap' : '.map',
    'application/mbedlet' : '.mbd',
    'application/x-magic-cap-package-1.0' : '.mc$',
    'application/mcad' : '.mcd',
    'application/x-mathcad' : '.mcd',
    'image/vasa' : '.mcf',
    'text/mcf' : '.mcf',
    'application/netmc' : '.mcp',
    'application/x-troff-me' : '.me',
    'message/rfc822' : '.mht',
    'message/rfc822' : '.mhtml',
    'application/x-midi' : '.mid',
    'audio/midi' : '.mid',
    'audio/x-mid' : '.mid',
    'audio/x-midi' : '.mid',
    'music/crescendo' : '.mid',
    'x-music/x-midi' : '.mid',
    'application/x-midi' : '.midi',
    'application/x-frame' : '.mif',
    'application/x-mif' : '.mif',
    'message/rfc822' : '.mime',
    'www/mime' : '.mime',
    'audio/x-vnd.audioexplosion.mjuicemediafile' : '.mjf',
    'video/x-motion-jpeg' : '.mjpg',
    'application/base64' : '.mm',
    'application/x-meme' : '.mm',
    'application/base64' : '.mme',
    'audio/mod' : '.mod',
    'audio/x-mod' : '.mod',
    'video/quicktime' : '.mov',
    'video/x-sgi-movie' : '.movie',
    'audio/mpeg' : '.mp2',
    'audio/x-mpeg' : '.mp2',
    'video/mpeg' : '.mpg',
    'video/x-mpeg' : '.mpg',
    'video/x-mpeq2a' : '.mpg',
    'audio/mpeg3' : '.mp3',
    'audio/x-mpeg-3' : '.mp3',
    'video/mpeg' : '.mpeg',
    'video/x-mpeg' : '.mpeg',
    'audio/mpeg' : '.mpa',
    'video/mpeg' : '.mpeg',
    'application/x-project' : '.mpc',
    'application/vnd.ms-project' : '.mpp',
    'application/x-project' : '.mpt',
    'application/x-project' : '.mpv',
    'application/x-project' : '.mpx',
    'application/marc' : '.mrc',
    'application/x-troff-ms' : '.ms',
    'video/x-sgi-movie' : '.mv',
    'audio/make' : '.my',
    'application/x-vnd.audioexplosion.mzz' : '.mzz',
    'image/naplps' : '.nap',
    'image/naplps' : '.naplps',
    'application/x-netcdf' : '.nc',
    'application/vnd.nokia.configuration-message' : '.ncm',
    'image/x-niff' : '.nif',
    'image/x-niff' : '.niff',
    'application/x-mix-transfer' : '.nix',
    'application/x-conference' : '.nsc',
    'application/x-navidoc' : '.nvd',
    'application/oda' : '.oda',
    'application/x-omc' : '.omc',
    'application/x-omcdatamaker' : '.omcd',
    'application/x-omcregerator' : '.omcr',
    'text/x-pascal' : '.p',
    'application/pkcs10' : '.p10',
    'application/x-pkcs10' : '.p10',
    'application/pkcs-12' : '.p12',
    'application/x-pkcs12' : '.p12',
    'application/x-pkcs7-signature' : '.p7a',
    'application/pkcs7-mime' : '.p7c',
    'application/x-pkcs7-mime' : '.p7c',
    'application/pkcs7-mime' : '.p7m',
    'application/x-pkcs7-mime' : '.p7m',
    'application/x-pkcs7-certreqresp' : '.p7r',
    'application/pkcs7-signature' : '.p7s',
    'application/pro_eng' : '.part',
    'text/pascal' : '.pas',
    'image/x-portable-bitmap' : '.pbm',
    'application/vnd.hp-pcl' : '.pcl',
    'application/x-pcl' : '.pcl',
    'image/x-pict' : '.pct',
    'image/x-pcx' : '.pcx',
    'chemical/x-pdb' : '.pdb',
    'application/pdf' : '.pdf',
    'audio/make' : '.pfunk',
    'audio/make.my.funk' : '.pfunk',
    'image/x-portable-graymap' : '.pgm',
    'image/x-portable-greymap' : '.pgm',
    'image/pict' : '.pic',
    'application/x-newton-compatible-pkg' : '.pkg',
    'application/vnd.ms-pki.pko' : '.pko',
    'text/x-script.perl' : '.pl',
    'application/x-pixclscript' : '.plx',
    'image/x-xpixmap' : '.pm',
    'text/x-script.perl-module' : '.pm',
    'application/x-pagemaker' : '.pm4',
    'application/x-pagemaker' : '.pm5',
    'application/x-pagemaker' : '.pm6',
    'image/png' : '.png',
    'application/x-portable-anymap' : '.pnm',
    'image/x-portable-anymap' : '.pnm',
    'model/x-pov' : '.pov',
    'image/x-portable-pixmap (used by GitHub)' : '.ppm',
    'application/mspowerpoint' : '.pptx',
    'application/powerpoint' : '.pptx',
    'application/vnd.ms-powerpoint' : '.pptx',
    'application/x-mspowerpoint' : '.pptx',
    'application/x-freelance' : '.pre',
    'application/pro_eng' : '.prt',
    'paleovu/x-pv' : '.pvu',
    'text/x-script.phyton' : '.py',
    'application/x-bytecode.python' : '.pyc',
    'audio/vnd.qcelp' : '.qcp',
    'x-world/x-3dmf' : '.qd3',
    'x-world/x-3dmf' : '.qd3d',
    'image/x-quicktime' : '.qif',
    'video/quicktime' : '.qt',
    'video/x-qtc' : '.qtc',
    'image/x-quicktime' : '.qti',
    'image/x-quicktime' : '.qtif',
    'audio/x-pn-realaudio' : '.ra',
    'audio/x-pn-realaudio-plugin' : '.ra',
    'audio/x-realaudio' : '.ra',
    'audio/x-pn-realaudio' : '.ram',
    'application/x-cmu-raster' : '.ras',
    'image/cmu-raster' : '.ras',
    'image/x-cmu-raster' : '.ras',
    'image/cmu-raster' : '.rast',
    'text/x-script.rexx' : '.rexx',
    'image/vnd.rn-realflash' : '.rf',
    'image/x-rgb' : '.rgb',
    'application/vnd.rn-realmedia' : '.rm',
    'audio/x-pn-realaudio' : '.rm',
    'audio/mid' : '.rmi',
    'audio/x-pn-realaudio' : '.rmm',
    'audio/x-pn-realaudio' : '.rmp',
    'audio/x-pn-realaudio-plugin' : '.rmp',
    'application/ringing-tones' : '.rng',
    'application/vnd.nokia.ringing-tone' : '.rng',
    'application/vnd.rn-realplayer' : '.rnx',
    'application/x-troff' : '.roff',
    'image/vnd.rn-realpix' : '.rp',
    'audio/x-pn-realaudio-plugin' : '.rpm',
    'text/richtext' : '.rt',
    'text/vnd.rn-realtext' : '.rt',
    'application/rtf' : '.rtf',
    'application/x-rtf' : '.rtf',
    'text/richtext' : '.rtf',
    'application/rtf' : '.rtx',
    'text/richtext' : '.rtx',
    'video/vnd.rn-realvideo' : '.rv',
    'text/x-asm' : '.asm',
    'audio/s3m' : '.s3m',
    'application/x-tbook' : '.sbk',
    'application/x-lotusscreencam' : '.scm',
    'text/x-script.guile' : '.scm',
    'text/x-script.scheme' : '.scm',
    'video/x-scm' : '.scm',
    'application/sdp' : '.sdp',
    'application/x-sdp' : '.sdp',
    'application/sounder' : '.sdr',
    'application/sea' : '.sea',
    'application/x-sea' : '.sea',
    'application/set' : '.set',
    'text/sgml' : '.sgm',
    'text/x-sgml' : '.sgm',
    'text/sgml' : '.sgml',
    'text/x-sgml' : '.sgml',
    'application/x-bsh' : '.sh',
    'application/x-sh' : '.sh',
    'application/x-shar' : '.sh',
    'text/x-script.sh' : '.sh',
    'application/x-bsh' : '.shar',
    'application/x-shar' : '.shar',
    'text/x-server-parsed-html' : '.shtml',
    'audio/x-psid' : '.sid',
    'application/x-sit' : '.sit',
    'application/x-stuffit' : '.sit',
    'application/x-koan' : '.skd',
    'application/x-koan' : '.skm',
    'application/x-koan' : '.skp',
    'application/x-koan' : '.skt',
    'application/x-seelogo' : '.sl',
    'application/smil' : '.smi',
    'application/smil' : '.smil',
    'audio/basic' : '.snd',
    'audio/x-adpcm' : '.snd',
    'application/solids' : '.sol',
    'application/x-pkcs7-certificates' : '.spc',
    'text/x-speech' : '.spc',
    'application/futuresplash' : '.spl',
    'application/x-sprite' : '.spr',
    'application/x-sprite' : '.sprite',
    'application/x-wais-source' : '.src',
    'application/streamingmedia' : '.ssm',
    'application/vnd.ms-pki.certstore' : '.sst',
    'application/step' : '.step',
    'application/sla' : '.stl',
    'application/vnd.ms-pki.stl' : '.stl',
    'application/x-navistyle' : '.stl',
    'application/step' : '.stp',
    'application/x-sv4cpio' : '.sv4cpio',
    'application/x-sv4crc' : '.sv4crc',
    'image/vnd.dwg' : '.svf',
    'image/x-dwg' : '.svf',
    'application/x-world' : '.svr',
    'x-world/x-svr' : '.svr',
    'application/x-shockwave-flash' : '.swf',
    'application/x-troff' : '.t',
    'text/x-speech' : '.talk',
    'application/x-tar' : '.tar',
    'application/toolbook' : '.tbk',
    'application/x-tbook' : '.tbk',
    'application/x-tcl' : '.tcl',
    'text/x-script.tcl' : '.tcl',
    'text/x-script.tcsh' : '.tcsh',
    'application/x-tex' : '.tex',
    'application/x-texinfo' : '.texi',
    'application/x-texinfo' : '.texinfo',
    'application/plain' : '.txt',
    'application/gnutar' : '.tgz',
    'application/x-compressed' : '.tgz',
    'image/tiff' : '.tiff',
    'image/x-tiff' : '.tiff',
    'application/x-troff' : '.tr',
    'audio/tsp-audio' : '.tsi',
    'application/dsptype' : '.tsp',
    'audio/tsplayer' : '.tsp',
    'text/tab-separated-values' : '.tsv',
    'image/florian' : '.turbot',
    'text/plain' : '.txt',
    'text/x-uil' : '.uil',
    'text/uri-list' : '.uni',
    'text/uri-list' : '.unis',
    'application/i-deas' : '.unv',
    'text/uri-list' : '.uri',
    'text/uri-list' : '.uris',
    'application/x-ustar' : '.ustar',
    'multipart/x-ustar' : '.ustar',
    'text/x-uuencode' : '.uu',
    'application/x-cdlink' : '.vcd',
    'text/x-vcalendar' : '.vcs',
    'application/vda' : '.vda',
    'video/vdo' : '.vdo',
    'application/groupwise' : '.vew',
    'video/vivo' : '.viv',
    'video/vnd.vivo' : '.viv',
    'video/vivo' : '.vivo',
    'video/vnd.vivo' : '.vivo',
    'application/vocaltec-media-desc' : '.vmd',
    'application/vocaltec-media-file' : '.vmf',
    'audio/voc' : '.voc',
    'audio/x-voc' : '.voc',
    'video/vosaic' : '.vos',
    'audio/voxware' : '.vox',
    'audio/x-twinvq-plugin' : '.vqe',
    'audio/x-twinvq' : '.vqf',
    'audio/x-twinvq-plugin' : '.vql',
    'application/x-vrml' : '.vrml',
    'model/vrml' : '.vrml',
    'x-world/x-vrml' : '.vrml',
    'x-world/x-vrt' : '.vrt',
    'application/x-visio' : '.vsd',
    'application/x-visio' : '.vst',
    'application/x-visio' : '.vsw',
    'application/wordperfect6.0' : '.w60',
    'application/wordperfect6.1' : '.w61',
    'audio/wav' : '.wav',
    'audio/x-wav' : '.wav',
    'application/x-qpro' : '.wb1',
    'image/vnd.wap.wbmp' : '.wbmp',
    'application/vnd.xara' : '.web',
    'application/x-123' : '.wk1',
    'windows/metafile' : '.wmf',
    'text/vnd.wap.wml' : '.wml',
    'application/vnd.wap.wmlc' : '.wmlc',
    'text/vnd.wap.wmlscript' : '.wmls',
    'application/vnd.wap.wmlscriptc' : '.wmlsc',
    'application/wordperfect6.0' : '.wp5',
    'application/wordperfect' : '.wpd',
    'application/x-wpwin' : '.wpd',
    'application/x-lotus' : '.wq1',
    'application/mswrite' : '.wri',
    'application/x-wri' : '.wri',
    'application/x-world' : '.wrl',
    'model/vrml' : '.vrml',
    'x-world/x-vrml' : '.vrml',
    'text/scriplet' : '.wsc',
    'application/x-wais-source' : '.wsrc',
    'application/x-wintalk' : '.wtk',
    'image/x-xbitmap' : '.xbm',
    'image/x-xbm' : '.xbm',
    'image/xbm' : '.xbm',
    'video/x-amt-demorun' : '.xdr',
    'xgl/drawing' : '.xgz',
    'image/vnd.xiff' : '.xif',
    'application/excel' : '.xlsx',
    'application/x-excel' : '.xlsx',
    'application/x-msexcel' : '.xlsx',
    'application/vnd.ms-excel' : '.xlsx',
    'audio/xm' : '.xm',
    'application/xml' : '.xml',
    'text/xml' : '.xml',
    'xgl/movie' : '.xmz',
    'application/x-vnd.ls-xpix' : '.xpix',
    'image/x-xpixmap' : '.xpm',
    'image/xpm' : '.xpm',
    'image/png' : '.x-png',
    'video/x-amt-showrun' : '.xsr',
    'image/x-xwd' : '.xwd',
    'image/x-xwindowdump' : '.xwd',
    'chemical/x-pdb' : '.xyz',
    'application/x-compressed' : '.zip',
    'application/x-zip-compressed' : '.zip',
    'application/zip' : '.zip',
    'multipart/x-zip' : '.zip',
    'text/x-script.zsh' : '.zsh',

    'application/x-msaccess' : ".mdb",
    'text/rtf' : ".rtf",
    'image/x-ms-bmp' : ".bmp",
    'application/vnd.lotus-wordpro' : ".wpd",
    'application/vnd.oasis.opendocument.text' : ".odt"
}


import os, magic
import tkinter as tk
from tkinter import filedialog, messagebox, simpledialog

root = tk.Tk()
root.withdraw()

base_path = r"D:\\Found.001\\"
base_path = filedialog.askdirectory(parent=root, initialdir="/", title='UnFOUNDchk :: Please select a directory with .chk files')

# Close if no folder selected
if base_path is None:
    exit()

try:
    with open(os.path.join(base_path, "000_UnFOUNDchk.log"), "w") as logfile:
        for subdir, dirs, files in os.walk(base_path):
            for f in files:
                path = os.path.join(subdir, f)
                if not os.path.isdir(path) and path.lower().endswith(".chk"):
                    mime_t = magic.from_file(path, mime=True)
                    ext = exts.get(mime_t, None)

                    # Check details for office- and binary files
                    if ext in [".docx" , ".pptx", ".xlsx", ".bin"]:
                        mime_det = magic.from_file(path).split(", ")
                        if mime_det[0] == "MS Windows shortcut":
                            ext = ".lnk"
                        elif mime_det[0].startswith("RIFF"):
                            ext = ".riff"
                        elif mime_det[0].startswith("Audio file with ID3"):
                            ext = ".mp3"
                        elif mime_det[0] == "Composite Document File V2 Document" or mime_det[0] == "CDFV2 Microsoft Word" or mime_det[0] == "Microsoft Excel Worksheet":
                            if ext == ".docx":
                                ext = ".doc"
                            elif ext == ".pptx":
                                ext = ".ppt"
                            elif ext == ".xlsx":
                                ext = ".xls"
                                
                        print(mime_det[0])
                    
                    if ext is not None:
                        new_path = path[0:-4] + ext
                        logfile.write(f"{f} -> {new_path} \n")
                        os.rename(path, new_path)
                    else:
                        s.add(mime_t)
                
        logfile.write(f"\n\n")
        logfile.write(f"UNKNOWN MIMETYPES:\n\n")
        for entry in s:
            logfile.write(f"{entry} \n")
            
except Exception as e:
    logfile.write(f"\n\nERROR: \n\n{e}")
    
#print(s)

Download Source       Download Windows EXE

System requrements:

Windows, OSX or Linux with