Assuming bash, the simplest change would be
PIC=$(ls $DIR/*.{jpg,png,gif} | shuf -n1)
Here is a sample on my car
$ export DIR=Desktop
$ PIC=$(ls $DIR/*.{jpg,png,gif} | shuf -n1)
$ echo $PIC
Desktop/polar.png
Instead, I recommend using a search for this.
sehe source
share