               (unless (equal (process-buffer proc)
                              (window-buffer (selected-window)))
                 (kill-buffer (process-buffer proc))))))
+      (with-current-buffer proc-buffer
+        (require 'shell)
+        (shell-mode))
       (setq dired-script--execs
             (push (cons (process-name proc)
                         (make-dired-script--exec :script script
                                                  :process proc
                                                  :name (process-name proc)
                                                  :calling-buffer (current-buffer)
+                                                 :files-before (dired-script--dired-files)
                                                  :reporter (make-progress-reporter (process-name proc))))
                   dired-script--execs))
       (set-process-sentinel proc #'dired-script--sentinel)

  ;; "<<fne>>.gif" with "/path/tmp.txt" -> "'/path/tmp.gif'"
  (setq template (replace-regexp-in-string "[[:blank:]]\\(\\(\<\<fne\>\>\\)\\([^ \n]+\\)\\([[:blank:]]\\|$\\)\\)"
                                           (format "'%s\\3'\\4" (file-name-sans-extension file)) template nil nil 1))
  (when post-process-template
    (setq template (funcall post-process-template template file)))
  template)

   "ffmpeg -loglevel quiet -stats -y -i <<f>> -pix_fmt rgb24 -r 15 <<fne>>.gif
    gifsicle -O3 <<fne>>.gif --lossy=80 -o <<fne>>.gif"
   "Convert to optimized gif" '("ffmpeg" "gifsicle")))

(defun dired-script-unzip ()
  "Unzip all marked archives (of any kind) using `atool'."
  (interactive)
  (dired-script--dired-execute-script-on-marked-files
   "atool --extract --explain <<f>>" "Unzip" '("atool")))

(defun dired-script-speed-up-gif ()
  "Speeds up gif(s)."
