import os
folder = 'H:/dataset/train/'
for enum,file_name in enumerate(os.listdir(folder)):
source = folder + file_name
destination = folder + y[enum]
os.rename(source, destination)
FileExistsError
Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_5280/52172921.py in <module>
5 source = folder + file_name
6 destination = folder + y[enum]
----> 7 os.rename(source, destination)
8 os.unlink(source) FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'H:/dataset/train/001d7af96b.jpg' -> 'H:/dataset/train/Badminton.jpg'
This is how destination and source look like
sorry for the bad explanation of the problem and English.**