I want to read the file type of a file and transfer to another folder using python. Is there’s a code in python that can read file type like “.mp3, .psd, .pdf, etc”
Thank you.
I want to read the file type of a file and transfer to another folder using python. Is there’s a code in python that can read file type like “.mp3, .psd, .pdf, etc”
Thank you.
You might want to check what is called "magic". Take a look at python libraries that deal with it like
https://pypi.org/project/python-magic/
In Unix (like) environments (linux, BSD, MacOs) you can use it as a command too, try file <file_name>
:
https://linux.die.net/man/5/magic