I'm trying to generate unique names. I know about UUID and I have generated my own plugin to generate unique IDs. But this question applies to multiple cases.
How do I create a WHILE that checks if a generated file name exists in a folder. if it exists, we generate a new file name.
Let's say we have a generator that generates: IOX and checks that folder (or mysql database) and the file IOX.jpg already exists. so we generate another file name. this time we get: PQE... and so on, until we find a free entry in the database or in the filesystem.