This is a quick reference for some of the common operations on filenames and paths in python3
import os
base=os.path.basename('/path/to/file.ext')
# base = 'file.ext'
import os
base_without_extension=os.path.splitext(os.path.basename('/path/to/file.ext'))[0]
# base_without_extension = 'file'
import os
directory_path = os.path.dirname('/path/to/file.ext')
# directory_path = '/path/to'