Sunday, July 20, 2008

Command Line Music Player!

mpg321 can be used to play mp3 files from command line. We can even create a playlist of all the songs stored in various directories and play the list via mpg321. If your songs are stored in various folders, the folder names can be appended to the file-names using the following script. First of all the spaces have to be removed from the file names (as described in a previous post). Then we can create the following script -

for i in *;
b=`echo $PWD\`$i;
echo $b >> playlist; # the file names are stored in "playlist"

this way the names of all the files in all the subdirectories will be stored in "playlist" along with the appropriate path. Then we can play the list
as follows -

$ mpg321 --list playlist -z # -z for shuffle mode

That is it! Enjoy your music! Here we are assuming that all files are stored in various subdirectories of one parent directory, say 'music'. The script has to executed from the directory 'music'.

No comments: