Code Sample |
#check if one commandline option is given, else exit if [ -z "$1" ]; then echo usage: $0 directory [searchstring] [shuffle] [add] exit fi #Pre define Folder and NULL files DIR=$1 #check if searchstring is * , cause * cant be as normal opperator, must be Space if [ "$2" = "*" ];then SS="" else SS=$2 fi FILES="" #get mp3 file list if [ "$4" = "add" ];then # if add=true,add to preexisting file, else create new one find $DIR -name \*$SS*.mp3 >> files.txt else find $DIR -name \*$SS*.mp3 > files.txt fi #create string to hand over to mplayer though handing over filelist wont work while read FILENAME do FILES=$FILES" "$FILENAME done < files.txt #execute mplayer with found files if [ "$3" = "shuffle" ];then #shuffle requested?? mplayer -z $FILES else mplayer $FILES fi |