Taking into consideration your comment, that it doesn't matter where in the path the name appears (i.e. both "C:\ABC123\test.png" and "C:\vol01\ABC123.xml" match the query "ABC123"), we do not take into consideration the structure of the file system paths, but can work on pure string matching.
Be paths the list of all paths, be names the list of all names, and be name the name you are looking for then
(path for path in paths if name in path)
is the generator yielding all paths matching name.
dict ( ( (name, [path for path in paths if name in path] ) for name in names) )
creates a dictionary whose keys are the names and whose values are all paths that contain the corresponding name. You can use it someway like that:
paths = [....]
names = [....]
d = dict ( ( (name, [path for path in paths if name in path] ) for name in names) )
print ('The name "ABC" is contained in: {}'.format (d ['ABC'] ) )
print ('The name "XYZ" is contained in: {}'.format (d ['XYZ'] ) )
print ('The name "pron" is contained in: {} different paths'.format (len (d ['pron'] ) if 'pron' in d else 0) )