I was working a project to play background music in a restaurant on the cheap. So I put together this small script to continuously play all the mp3 files in a directory in Linux. This was written and tested on Ubuntu 10.04, but should work as long as mpg123 is installed. Any old box you have laying around that can run Ubuntu should have no problems running this script. The tricky part was getting the script to work when there are spaces in the file names. The `read file` command was the solution to the space in the mp3 filenames issue.
Put the script below into a file, make it executable, and pass the directory with the mp3s you want to play on the command line.
#!/bin/bash
while sleep 1; do
find "$1" -type f |grep .mp3$ |while read file; do
mpg123 "$file"
done
done
Sunday, December 12, 2010
Subscribe to:
Comments (Atom)
About Me
- Walter Spurgiasz
- FOOTHILL RANCH, CA, United States