There are lots of places where we have Path(filepath) where filepath is a pathlib.Path. This is unnecessary. Once we have a pathlib.Path object, additional operations produce pathlib.Path objects.
All of the following produce pathlib.Path objects.
filepath1 = filepath.parent
filepath2 = filepath / "subdir"
Additionally, we should replace use of os (e.g., os.join, os.makedirs, etc) with pathlib.Path methods. The code is more concise and easier to read.