Split a file path into dir and file:
import os head, tail = os.path.split('/path/to/file.txt') print(head) # '/path/to' print(tail) # 'file.txt'