   (when post-process-template
     (setq template (funcall post-process-template template file)))
   template)
+
+(defun dwim-shell-command--contains-single-file-ref (template)
+  (cond ((string-match "\<\<f\>\>" template)
+         "<<f>>")
+        ((string-match "\<\<fne\>\>" template)
+         "<<fne>>")
+        ((string-match "\<\<e\>\>" template)
+         "<<e>>")))
+
+(defun dwim-shell-command--contains-multi-file-refs (template)
+  (when (string-match "\<\<\\*\>\>" template)
+    "<<*>>"))
 
 (defun dwim-shell-command--default-directory-files ()
   "List of files in current buffer's `default-directory'."

Use POST-PROCESS-TEMPLATE to further expand template given own logic.

Set TEMP-DIR to a unique temp directory to this template."
  (setq file (expand-file-name file))
  ;; "<<fne>>" with "/path/tmp.txt" -> "/path/tmp"
  (setq template (replace-regexp-in-string "\\(\<\<fne\>\>\\)" (file-name-sans-extension file) template nil nil 1))

         (progress-reporter))
    (if (seq-empty-p files)
        (setq script template)
      (when extensions
        (seq-do (lambda (file)
                  (cl-assert (seq-contains-p extensions (downcase (file-name-extension file)))
                             nil "Not a .%s file" (string-join extensions " .")))
                files))
      (if (dwim-shell-command--contains-multi-file-refs template)
          (setq script (dwim-shell-command--expand-files-template template files post-process-template gen-temp-dir))
        (seq-do (lambda (file)
                  (setq script
                        (concat script "\n"
                                (dwim-shell-command--expand-file-template template file post-process-template gen-temp-dir))))
                files)))
    (setq script (string-trim script))
    (seq-do (lambda (util)
              (cl-assert (executable-find util) nil
