import os full_name = 'directory/file.ext' name_without_ext = os.path.basename(os.path.splitext(full_name)[0])