                              nil "Not a .%s file" (string-join extensions " .")))
                 (setq script
                       (concat script "\n"
-                              (dwim-shell-command--expand template file post-process-template))))
+                              (dwim-shell-command--expand template file post-process-template gen-temp-dir))))
               files))
     (setq script (string-trim script))
     (seq-do (lambda (util)


  ;; "<<f>>" with "/path/file.jpg" -> "/path/file.jpg"
  (setq template (replace-regexp-in-string "\\(\<\<f\>\>\\)" file template nil nil 1))
  (when post-process-template
    (setq template (funcall post-process-template template file)))
  template)

    (setq shell-args (list shell-args)))
  (when (stringp utils)
    (setq utils (list utils)))
  (when (or gen-temp-dir (string-match-p "\<\<td\>\>" script 0))
    (setq gen-temp-dir (make-temp-file "dwim-shell-command-" t)))
  (let* ((proc-buffer (generate-new-buffer buffer-name))
         (template script)
         (script "")
