Hi all! I’m reading the wonderful Python for coders, and I noticed in chapter 2 that, once you want to move images using your
ImageClassifierCleaner, it’s possible that you try to move an image that has the same filename in the destination folder. In that case, it’s not going to move it because that file already exists:
This is the line that appears in the book to move the images from the ImageClassifierCleaner:
for idx,cat in cleaner.change(): shutil.move(str(cleaner.fns[idx]), path/cat/)
For example, if I have 2 categories folder:
- grizzy - 1.jpg - 2.jpg ... - teddy - 1.jpg - 2.jpg ...
If I need to move the 2.jpg of the
teddy folder to the
grizzy folder, it’s not gonna move it unless it has a different filename (because there is already a 2.jpg file in the directory where you want to move the image).
Am I getting this wrong? If it’s actually an error, is there any way to handle it? I was thinking in renaming the image before you move it, but not sure how to do that.
Thanks in advance!