Package: get-file-type
Guesses the file type/mime/encoding of filespip install get-file-typeGuessesthefiletype/mime/encodingoffiles.Itusesthebinariesfromhttps://github.com/julian-r/file-windows/releases(FileandLibmagicbuildwithVisualStudio)-TheyareincludedinthispackageArgs:files_folders(listorstr):Alistoffile/folderpathsorasinglefile/folderpath.maxsubfolders(int,optional):Maximumnumberofsubfolderstoscan.Defaultis-1,whichmeansnolimit.pandas_dataframe(bool,optional):DeterminesiftheresultsshouldbereturnedasapandasDataFrame.Requirespandastobeinstalled.DefaultisFalse.verbose(bool,optional):Determinesifverboseoutputshouldbedisplayed.DefaultisTrue.Returns:listorpd.DataFrame:AlistoffiletypeinformationforeachfileorapandasDataFrameifpandas_dataframeisTrue.Raises:Exception:Ifpandasisnotinstalledandpandas_dataframeissettoTrue.Example:fromget_file_typeimportguess_filetypesresult_list=guess_filetypes(files_folders=[r"C:\Users\hansc\Pictures\fastcpy",# png file without endingr"C:\Users\hansc\Pictures\fastcpy - Copy.png",# an actual png file, to check if files with the correct ending are ignoredr"C:\Users\hansc\Pictures\cppcomp.jpg",# a .txt file with the wrong endingr"E:\destinationcopytemp5",# internet cache files - whole folder will be scanned],maxsubfolders=-1,# if you want to limit the number of subfolders to scan, -1 means no limitpandas_dataframe=False,# return the results as a pd.DataFrame (pandas must be installed)verbose=True,# visual output)result_df=guess_filetypes(files_folders=[r"C:\Users\hansc\Pictures\fastcpy",# png file without endingr"C:\Users\hansc\Pictures\fastcpy - Copy.png",# an actual png file, to check if files with the correct ending are ignoredr"C:\Users\hansc\Pictures\cppcomp.jpg",# a .txt file with the wrong endingr"E:\destinationcopytemp5",# internet cache files - whole folder will be scanned],maxsubfolders=-1,pandas_dataframe=True,verbose=True,)output:[[['C:\\Users\\hansc\\Pictures\\fastcpy','image/png','charset=binary',('png',),('C:\\Users\\hansc\\Pictures\\fastcpy.png',)]]][[['C:\\Users\\hansc\\Pictures\\fastcpy - Copy.png','image/png','charset=binary',('png',),('C:\\Users\\hansc\\Pictures\\fastcpy - Copy.png',)]]][[['C:\\Users\\hansc\\Pictures\\cppcomp.jpg','text/plain','charset=us-ascii',('conf','def','in','ini','list','log','text','txt'),('C:\\Users\\hansc\\Pictures\\cppcomp.jpg.conf','C:\\Users\\hansc\\Pictures\\cppcomp.jpg.def','C:\\Users\\hansc\\Pictures\\cppcomp.jpg.in','C:\\Users\\hansc\\Pictures\\cppcomp.jpg.ini','C:\\Users\\hansc\\Pictures\\cppcomp.jpg.list','C:\\Users\\hansc\\Pictures\\cppcomp.jpg.log','C:\\Users\\hansc\\Pictures\\cppcomp.jpg.text','C:\\Users\\hansc\\Pictures\\cppcomp.jpg.txt')]]][[['E:\\destinationcopytemp5\\00000000__2023_05_13_22_33_46\\Users\\hansc\\AppData\\Local\\Temp\\RBX-64BA6ED6.log','text/plain','charset=us-ascii',('conf','def','in','ini','list','log','text','txt'),('E:\\destinationcopytemp5\\00000000__2023_05_13_22_33_46\\Users\\hansc\\AppData\\Local\\Temp\\RBX-64BA6ED6.log',)]]][[['E:\\destinationcopytemp5\\00000000__2023_05_13_22_33_46\\Users\\hansc\\AppData\\Local\\Temp\\RBX-DF39BC9A.log','text/plain','charset=us-ascii',('conf','def','in','ini','list','log','text','txt'),('E:\\destinationcopytemp5\\00000000__2023_05_13_22_33_46\\Users\\hansc\\AppData\\Local\\Temp\\RBX-DF39BC9A.log',)]]]aa_filenameaa_mimeaa_encodingaa_possible_extensionsaa_possible_filenames0C:\Users\hansc\Pictures\fastcpyimage/pngcharset=binary(png,)(C:\Users\hansc\Pictures\fastcpy.png,)1C:\Users\hansc\Pictures\fastcpy-Copy.pngimage/pngcharset=binary(png,)(C:\Users\hansc\Pictures\fastcpy-Copy.png,)2C:\Users\hansc\Pictures\cppcomp.jpgtext/plaincharset=us-ascii(conf,def,in,ini,list,log,text,txt)(C:\Users\hansc\Pictures\cppcomp.jpg.conf,C:\Users\hansc\Pictures\cppcomp.jpg.def,C:\Users\hansc\Pictures\cppcomp.jpg.in,C:\Users\hansc\Pictures\cppcomp.jpg.ini,C:\Users\hansc\Pictures\cppcomp.jpg.list,C:\Users\hansc\Pictures\cppcomp.jpg.log,C:\Users\hansc\Pictures\cppcomp.jpg.text,C:\Users\hansc\Pictures\cppcomp.jpg.txt)3E:\destinationcopytemp5\00000000__2023_05_13_22_33_46\Users\hansc\AppData\Local\Temp\RBX-64BA6ED6.logtext/plaincharset=us-ascii(conf,def,in,ini,list,log,text,txt)(E:\destinationcopytemp5\00000000__2023_05_13_22_33_46\Users\hansc\AppData\Local\Temp\RBX-64BA6ED6.log,)4E:\destinationcopytemp5\00000000__2023_05_13_22_33_46\Users\hansc\AppData\Local\Temp\RBX-DF39BC9A.logtext/plaincharset=us-ascii(conf,def,in,ini,list,log,text,txt)(E:\destinationcopytemp5\00000000__2023_05_13_22_33_46\Users\hansc\AppData\Local\Temp\RBX-DF39BC9A.log,)