In the folder ”.\my_folder\subfolder\subsubfolder" there are files named:
I want to rename them changing A to B:
os.path.abspath is used to normalize the path (independently of the OS).
glob.glob returns the list af all file paths matching the input string.
A(?=_\d+\.txt$) looks for a A that preceeds a string of the type “_##ANY_NUMBER##.txt”.
(?<=file)A checks that A is preceeded by the string “file”.