I use the file explorer called ranger and I wonder if it is possible to open many files in different directory with mplayer?

What I can already do is to select all the files (pressing v) from one directory and then press Enter. Mplayer is launched and all the files in that directory are played one after the other.

But what if I want to play a list of files that are in different directories?

EDIT: To be more general, I'd like to know how to run a command that takes files from different directories as arguments.

4 Answers 4


Answer from: http://ranger.carina.uberspace.de/qa/358/open-several-marked-files. I tested this and it works.

Marking is limited to 1 directory. To open files in multiple directories, you need to use the copy buffer instead:

  1. Move to a file you want to use and type "ya" to add the file to the copy buffer. If you mark files with space or v, they will all be added at the same time.
  2. Type:

    :shell command %c

    To use all the files with the given command. %c is expanded to all the files of the copy buffer.

  3. Finally type "uy" to reset the copy buffer.
  • thanks, that works but it's quite unpractical...
    – PinkFloyd
    Commented Nov 4, 2013 at 10:19
  • 1
    @PinkFloyd maybe because your demand is unpractical or you should use smplayer which has gui
    – mnors
    Commented Nov 4, 2013 at 19:49

You should use smplayer (the best GUI for mplayer, which supports all the features mplayer has) instead of mplayer (which is a command line tool).

If your open command for audio files looks like this

smplayer -add-to-playlist

the selected files will be added to smplayer’s internal playlist. You can easily select and add files from different directories to be played.


Here is my solution for playing all files in a directory and all subdirectories with mplayer2 and ranger in random order. It's is not exactly the answer to the question, but maybe you can expand it.

First I wrote a shell script called ptv:


if [[ -z "$1" ]]; then
  echo "usage: $(basename $0) directory [count]"
  if [[ ! -z "$2" ]]; then
  CWD="$(realpath "$1")"
  find "$CWD" -type f -iname \*.mkv -or -iname \*.mp4 -or -iname \*.avi | shuf $SHUFPARAM > $PLAYLIST && \
    mplayer2 --playlist=$PLAYLIST && rm -f $PLAYLIST

This script finds all my movie files in a given directory, creates a random ordered playlist and calls mplayer2 with this generated playlist. Leave the shuf command out, if you want a sorted list.

Next step is to edit rifle.conf in your settings directory (~/.config/ranger). Add this line:

directory, label pseudoTV, has mplayer2, flag f = /path/to/ptv "$@"

Now you can use the script to open_with (mapped to key: r) with mplayer2. In mplayer2 you can navigate with < and > between the playlist items.

TIP: Copy your directories directories to the yank_buffer and save it in ranger. Then expand ptv to find files in all your selected directories...


You better use a command line interface to launch mplayer, in Linux it is shell, look at my command:

~bash~ $ mplayer 1st_screen/JacksonSisters-IBelieveInMiracles.mp3 \
> 2nd_screen/\(15\)\ Memory\ Gospel\ -\ Moby.flac \
> 3rd_screen/01\ -\ Iggy\ Pop\ -\ Livin\'\ on\ the\ Edge\ of\ the\ Night.flac \
> 4th_screen/05\ -\ We\ Must\ Believe\ In\ Magic.flac 

Where 1st_screen, 2nd_screen, 3rd_screen, 4th_screen is a different directories.

You can always launch two instance of mplayer at one moment in different shells, two songs will make noise simultaneously.

  • i knew that command but thx. this command is not practical when you want to open a lot of files because you need to write them all (or use a * if you want to select many files). ranger provides a way to select files with v or space that is very useful.
    – PinkFloyd
    Commented Aug 28, 2013 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .