[Solved] Adding a suffix to a full path’s name, before the extension [duplicate]


Mixing some of your approaches, you can also do:

from pathlib import Path

path = Path("/a/b/c/file.txt")
path.with_name(path.stem + '_test' + path.suffix)
# PosixPath('/a/b/c/file_test.txt')

0

solved Adding a suffix to a full path’s name, before the extension [duplicate]