   (interactive)
   (let ((factor (string-to-number
                  (completing-read "Speed up x times: " '("1" "1.5" "2" "2.5" "3" "4")))))
-    (dwim-shell--dired-execute-script-on-marked-files
+    (dwim-shell--command-on-marked-files
      (format "gifsicle -U <<f>> <<frames>> -O2 -o <<fne>>_x%s.<<e>>" factor)
      "Speed up gif" '("gifsicle" "identify")
      (lambda (script file)

    (setq template (funcall post-process-template template file)))
  template)

(defun dwim-shell--default-directory ()
  "List of files in current buffer's `default-directory'."
  (cond ((equal major-mode 'dired-mode)
         (dwim-shell--dired-files))

(defun dwim-shell-drop-video-audio ()
  "Drop audio from all marked videos."
  (interactive)
  (dwim-shell--command-on-marked-files
   "ffmpeg -i <<f>> -c copy -an <<fne>>_no_audio.<<e>>"
   "Drop audio" '("ffmpeg")))

(defun dwim-shell--command-on-marked-files (script name utils &optional post-process-template on-completion)
  "Execute SCRIPT, using buffer NAME, FILES, and bin UTILS."
  (dwim-shell-execute-script script name (dwim-shell--marked-files) utils
                             post-process-template on-completion))

(defun dwim-shell--marked-files ()
  "Return buffer file (if available) or marked files for a `dired' buffer."
  (if (buffer-file-name)
      (list (buffer-file-name))
    (dired-get-marked-files)))

(defun dwim-shell-execute-script (script name files utils &optional post-process-template on-completion)
  "Execute SCRIPT, using buffer NAME, FILES, and bin UTILS."
