Windows solution
Here is a script which calls mplayer on every file in a directory including subfolders:The script will work on dirs containing spaces and non-ascii characters since all file names are converted to short dos names (via the `~s` modifier).
set mplayer=z:\path_to_mplayer\mplayer.exe
for /f "delims=" %%f in ('dir /b /s "%cd%"') do (%mplayer% "%%~sf")
Linux bash solution
The bash shell solution is much easier to read than the windows one:#!/bin/sh
cwd=`pwd`
for f in `find $cwd -type f -iname "*.mp3" `; do
mplayer $f
done
A Better Solution
An alternative solution for both Windows and Linux would be to create a playlist file first, and then run a single mplayer instance with the-playlist
switch:
Linux bash
#!/bin/sh
find $pwd -type f -iname "*.mp3" > /tmp/allfiles.m3u
mplayer -playlist /tmp/allfiles.m3u
Windows Batch
set mplayer=z:\path_to_mplayer\mplayer.exe
set playlist=%TEMP%/mp3playlist.m3u
dir /b /s "%cd%" | find /I ".mp3" > "%playlist%"
%mplayer% -playlist "%playlist%"
Shortest solution
mplayer $(find . -iname "*.mp3")
what about:
ReplyDeletefind . -iname "*.mp3" -exec mplayer {} \;
?
2spen:
ReplyDeletejust like the `for each` solution `-exec` will start a new instance of mplayer for each file, which might or might not be what is desired.
The playlist-based solution will simply feed the playlist to a single mplayer instance which is probably better in most cases.