   process
   name
   calling-buffer
-  reporter)
+  reporter
+  on-completion
+  files-before)
 
 (defun dired-script-convert-audio-to-mp3 ()
   "Convert all marked audio to mp3(s)."

   "ffmpeg -i <<f>> -c copy -an <<fne>>_no_audio.<<e>>"
   "Drop audio" '("ffmpeg")))

(defun dired-script--dired-execute-script-on-marked-files (script name utils &optional post-process-template)
  "Execute SCRIPT, using buffer NAME, FILES, and bin UTILS."
  (cl-assert (equal major-mode 'dired-mode) nil "Not in dired-mode")
  (dired-script-execute-script script name (dired-get-marked-files) utils
                               post-process-template))

(defun dired-script-execute-script (script name files utils &optional post-process-template)
  "Execute SCRIPT, using buffer NAME, FILES, and bin UTILS."
  (cl-assert (not (string-empty-p script)) nil "Script must not be empty")
  (cl-assert name nil "Script must have a name")
  (let* ((proc-buffer (generate-new-buffer name))
         (template script)
         (script "")
         (proc))
    (if (seq-empty-p files)
        (setq script template)

              (cl-assert (executable-find util) nil
                         (format "%s not installed" util)))
            utils)
    (with-current-buffer proc-buffer
      (setq default-directory default-directory)
      (shell-command-save-pos-or-erase)
      (view-mode +1)
      (setq view-exit-action 'kill-buffer))
    (setq files-before (dired-script--dired-files))
    (setq proc (start-process (buffer-name proc-buffer) proc-buffer "zsh" "-x" "-c" script))
    (if (equal (process-status proc) 'exit)
        (progn
          (if (= (process-exit-status proc) 0)
              (progn
                (when on-completion
                  (funcall on-completion))
                (with-current-buffer (current-buffer)
                  (when revert-buffer-function
                    (funcall revert-buffer-function))
                  (when-let* ((files-after (dired-script--dired-files))
                              (oldest-new-file (car (last (seq-sort #'file-newer-than-file-p
                                                                    (seq-difference files-after
                                                                                    files-before))))))
                    (dired-goto-file oldest-new-file)))
                (unless (equal (process-buffer proc)
                               (window-buffer (selected-window)))
                  (kill-buffer (process-buffer proc))))
