What I have made so far:

fileNames = []
for imageName in glob.glob("./TheAugmentedImages/*.jpg"):
  pattern = "(?<=_).*?(?=-)"
  fn = re.search(pattern, imageName)

subdirNames = []
for subdirectories in glob.glob("./adata/*"):
  pattern2 = "[0-9].*"
  sn = re.search(pattern2, subdirectories)

intersection = [value for value in fileNames if value in subdirNames]

files (images) that must go in subdirectories
subdirectories in which files must go

I want the files of directory TheAugmentedImages which have a particular pattern in filename to be in directories (of the directory adata) that has this pattern in directory name where "*" are subdirectories of the adata directory in which files must go

🔴 No definitive solution yet