In what file pattern are the images saved?

Hello,

The images, including the thumbnails and smaller sized images are saved in the upload folder. But they are saved in separate folders.

On what basis are the images saved like this? Is it that after a certain number of images, another folder is created? Or based on time?

Thanks