#!/bin/bash ## first i check that we have a player. i use sox. ## if you use something else set this to match your player [ -z sox ] && echo "install sox" && exit 1 if [ -f "$1" ] then # simply play the sound file. else look for sub-dirrectories if echo "$1" | grep -ie 'cdrom' > /dev/null 2>&1 # if it's on the cdrom drive then set the speed to 1X then eject -x 1 /dev/cdrom > /dev/null 2>&1 fi > /dev/null 2>&1 play "$1" > /dev/null 2>&1 # i didn't like the scrolling numbers sox displays so it's nulled. elif [ -d "$1" ] then # for directories, play all audio files within. LIST="`find $1 -type f`" C='1' BOB="`for Q in $LIST do if file $Q | grep audio > /dev/null 2>&1 then echo "$RANDOM:$Q" fi done | sort | cut -d':' -f2- `" for NEXT in $BOB do echo "#$C Now playing, \"`basename "$NEXT"`\" " $0 "$NEXT" > /dev/null 2>&1 C="$(($C + 1))" done else find ~/ /usr/local/ -name $1 -exec play '{}' \; fi