shuffling mp3 files with spaces causes problems
Posted: Mon Dec 19, 2016 7:06 pm
I am trying to loop and shuffle the mp3 files in a directory so I can play them randomly and continuously. So I created this script.
When the mp3 file doesn't have any spaces in its name, omxplayer plays the mp3 just fine. When there's a space in the name of the mp3 file, the script tries to play the word before, and the word after the space, as two separate mp3 files.
How can I prevent the script from thinking that there's two files?
Code: Select all
#!/bin/bash
# import variables
source "${BASH_SOURCE%/*}/variables"
# loop & shuffle
while true
do
for audio in $(ls $localaudiomedia/* | shuf)
do
echo "playing $audio"
sudo omxplayer --no-osd $audio > /dev/null
done
doneHow can I prevent the script from thinking that there's two files?