I am trying to create a shell script in Linux that when executed searches a directory for all media files then creates a playlist and plays it with MPlayer.
Asked
Active
Viewed 1.3k times
6
-
1When faced with a task like this, typically you will want to break it down into steps. Which part have you done so far? (1) Search a directory for all files. (2) Select the media files from a list of files. (3) Create a playlist file from the list of media files. (4) Start mplayer with the given playlist. – Greg Hewgill Apr 08 '12 at 20:54
-
i Search the directory for the files – RoundRobin Apr 08 '12 at 21:07
-
not sure how to create the playlist n start mplayer – RoundRobin Apr 08 '12 at 21:07
-
OK I FIGURED IT OUT THANKS ANYWAYS – RoundRobin Apr 08 '12 at 21:38
1 Answers
14
Use this command :
find /PATH/TO/MUSIC/DIRECTORY/ -type f -iname "*.mp3" > playlist.m3u
Now play with mplayer :
mplayer -playlist playlist.m3u

mah454
- 1,571
- 15
- 38
-
add "sort" to the find, otherwise it won't add the playlist in the right order: find /PATH/TO/MUSIC/DIRECTORY/ -type f -iname "*.mp3" | sort > playlist.m3u – Asaf Nov 19 '14 at 12:03