I would like to write a simple bash script that randomly selects a .flac
file from the /music/
folder (it will have to be recursive because there are many subfolders within that folder), and copy that file to /test/random.flac
This post is very close to what I want to do but I'm not sure how to change the script to do what I want.
I tried this:
ls /music |sort -R |tail -1 |while read file; do
cp $file /test/random.flac
done
But I'm missing how to tell ls
to do a recursive search of all the .flac
inside the subfolders.