Below code successfully creates all folder with same as image names. Now, I want to move images with same name inside same folder. This code creates folders but images were not moved inside folders.
import os
import shutil
images = os.listdir(os.getcwd())
print(images)
ids = set(i.split('_')[0] for i in images) # set removes duplicates
for i in ids:
os.mkdir(i) # create subdirs
for img in images:
target_dir = img.split('_')[0]
shutil.move(img, target_dir)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…