Topic: Code designed for 20 images, will it randomly choose 20 out of 40?

Is there a way to have a gallery designed for 20 images, but have it choose the 20 images at random out of a folder of 40 images?