I have an audio sample library with thousands of files. I would like to shuffle/randomize the order of these files. Can someone provide me with a bash script/line that would prepend a single random character to all files in a folder (including files in sub-folders). I do not want to prepend a random character to any of the folder names though.

---

**Example:**  

Kickdrum73.wav  

Kickdrum SUB.wav  

Kick808.mp3

**Renamed to:**  

f\_Kickdrum73.wav  

!\_Kickdrum SUB.wav  

4\_Kick808.mp3

---

If possible, I would like to be able to run this script more than once, but on subsequent runs, it just changes the randomly prepended character instead of prepending a new one.

Some of my attempts:

```
find ~/Desktop/test -type f -print0 | xargs -0 -n1 bash -c 'mv "$0" "a${0}"'    
find ~/Desktop/test/ -type f -exec mv -v {} $(cat a {}) \;   
find ~/Desktop/test/ -type f -exec echo -e "Z\n$(cat !)" > !Hat 15.wav    
for file in *; do    
    mv -v "$file" $RANDOM_"$file"    
done

```

Note: I am running on macOS.

---

Latest attempt using code from mr. fixit:

```
find . -type f -maxdepth 999 -not -name ".*" |
cut -c 3- - |
while read F; do
    randomCharacter="${F:2:1}"
    if [ $randomCharacter == '_' ]; then
        new="${F:1}"
    else
        new="_$F"
    fi
    fileName="`basename $new`"
    newFilename="`jot -r -c $fileName 1 A Z`"
    filePath="`dirname $new`"
    newFilePath="$filePath$newFilename"
    mv -v "$F" "$newFilePath"
done

```