play local music

17 06 2011

$ playall $1 [noshuffle]

…and don’t forget change line 6, according to the place your music is in

#!/bin/bash
# play all files in subdirectories containing $1 in file- or directory name
# noshuffle option is optional =)
# requires mplayer (alternate choice possible)
#
# switch to music directory
cd /media/data/music
# look for files containing $1, create playlist
echo ...looking for music files...
find | grep -i $1 > $1.pls
echo ...files found:
cat $1.pls
# calculate the number of files found
numfiles=$(echo "$(wc -l $1.pls | sed 's/[a-z]*.pls//g')-1" | bc -l)
echo ...$numfiles files were found...
echo ...starting playback...
# play files, output only main information (via grep)
if [ "$2" = "noshuffle" ]
        then mplayer -playlist $1.pls | grep Playing
        exit 1
        else mplayer -shuffle -playlist $1.pls | grep Playing
fi
# tidy up
rm $1.pls

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: