The problem: I've for example 16 tracks in one folder but I only want to play 1 - 7. How do I do this in MPlayer? The following:
mplayer 1.mp3 - 7.mp3
is not the right way. Is it even possible in MPlayer without writing out every filename?
As far as I am aware this is not possible from within MPlayer itself but a little command line magic can produce some great results.
The following is perhaps a little clumsy but works well enough here with the naming convention that you have specified:
mplayer $(find . -maxdepth 1 -name "[1-7].mp3" | ls -v)
Brief explanation:
find . -maxdepth 1
: Search in the current directory with no recursion.-name "[1-7].mp3"
: Find mp3s that have only the numerals 1-7 as their filename. The [1-7]
section demonstrates Bash range expression where numbers 1 and 7 are matched as well as all numbers between.ls -v
: Sort the search so the playback will be numerically based.Doubtless there are other ways but this works well enough and if your actual filenames are different it would be simply a matter of changing the regular expression in the find
syntax to match...
ls
, does it?
In this case, the only other tool you need is your shell command line.
mplayer [1-7].mp3
That example uses shell globbing (aka pathname expansion) to select the files you want to play. However, if you want to play tracks 8 to 11, for example, it should look more like this:
mplayer [89].mp3 1[01].mp3
For more information see 2.13. Pattern Matching Notation in the Posix specification, especially the sub-section 2.13.3 Patterns Used for Filename Expansion.
Also see the Pathname Expansion section of your shell man page ($man sh
) and the section following that about Shell Pattern Matching.