I have a list of file directories that looks similar to this:
path/new/stuff/files/morefiles/A/file2.txt
path/new/stuff/files/morefiles/B/file7.txt
path/new/stuff/files/morefiles/A/file1.txt
path/new/stuff/files/morefiles/C/file5.txt
I am trying to remove the beginnings of the paths that are the same from every list, and then deleting that from each file.
The list can be any length, and in the example I would be trying to change the list into:
A/file2.txt
B/file7.txt
A/file1.txt
C/file5.txt
Methods like re.sub(r'.*I', 'I', filepath)
and filepath.split('_', 1)[-1]
can be used for the replacing, but I'm not sure about how to find the common parts in the list of filepaths
Note:
I am using Windows and python 3