5

I have multiple short videos in a directory and I have to play all of them in a queue.

By using a file manager(Nautilus), I can select videos and then right click, select vlc and all videos will be played in a queue.

enter image description here

In dired, i can place point on a video and press enter which plays that video.

I tried selecting/marking multiple videos and press enter but i cant get all videos to play. How to do achieve that in emacs?

Chillar Anand
  • 4,042
  • 1
  • 23
  • 52

2 Answers2

8

Mark the videos with m and then use ! to run on shell command on each of them. You can specify your operating system's equivilent of an open-anything command such as open, xdg-open, gnome-open etc or use a specific one like vlc in this case.

This will open all the files by running the shell command on each of them. However if you want to pass all the files to one shell command like this:

open file.avi file2.avi

instead of this:

open file1.avi
open file2.avi

You can specify your shell command like this:

open *

From the docs of dired-do-shell-command:

If there is a ‘*’ in COMMAND, surrounded by whitespace, this runs COMMAND just once with the entire file list substituted there.

You can read more about this here or by reading the docs for dired-do-shell-command inside Emacs.

Jordon Biondo
  • 12,332
  • 2
  • 41
  • 62
3

I've described my approach to this here. Here's the code:

(require 'dired-aux)
(defvar dired-filelist-cmd
  '(("vlc" "-L")))
(defun dired-start-process (cmd &optional file-list)
  (interactive
   (let ((files (dired-get-marked-files
                 t current-prefix-arg)))
     (list
      (dired-read-shell-command "& on %s: "
                                current-prefix-arg files)
      files)))
  (let (list-switch)
    (start-process
     cmd nil shell-file-name
     shell-command-switch
     (format
      "nohup 1>/dev/null 2>/dev/null %s \"%s\""
      (if (and (> (length file-list) 1)
               (setq list-switch
                     (cadr (assoc cmd dired-filelist-cmd))))
          (format "%s %s" cmd list-switch)
        cmd)
      (mapconcat #'expand-file-name file-list "\" \"")))))
(define-key dired-mode-map "r" 'dired-start-process)

Mark the video files and press r.

abo-abo
  • 13,943
  • 1
  • 29
  • 43