python get base file and base directory code example Example: file base name and extension python from pathlib import Path Path('/root/dir/sub/file.ext').stem