type_of_file = file.split(".")[-1] might be more intuitive and less error prone for filenames with multiple dots.
PEP8 encourages the avoidance of bare excepts. https://realpython.com/the-most-diabolical-python-antipattern/
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.