How to set file name unique in the loop function?

So when we run this code to populate bears

if not path.exists():
    path.mkdir()
    for o in bear_types:
        dest = (path/o)
        dest.mkdir(exist_ok=True)
        results = search_images_bing(key, f'{o} bear')
        download_images(dest, urls=results.attrgot('contentUrl'))

the file names in each folder are the same…
image
image
image

This becomes problematic when you try to move files from one folder to another with the ImageClassifierCleaner function as it will throw an error because it would think the file already exist in the other folder.

I found this out when I tried to move images from one folder to another folder with the:

for idx,cat in cleaner.change(): shutil.move(str(cleaner.fns[idx]), path/cat)

is there a way to have all the files have a unique id name???
any recommendation on how to do that in the loop function???

Hi,
You can rename the files when downloading or renmae the files before moving them.
Check this link to see the code: