Adding random suffixes to filenames
If you just want to append a randomized string the for loop is rather simple:

cd ~/Desktop/test/
for file in *; do
    suffix="${file##.*}"
    base="${file%.*}"
    mv "$file" "$base.$(rand_string 10).$suffix"
done


Change the 10 to the number of random characters you want to add.