   (setq template (replace-regexp-in-string "[[:blank:]]\\(\<\<f\>\>\\)\\([[:blank:]]\\|$\\)"
                                            (format "'%s'" file)
                                            template nil nil 1))
+  ;; "<<f>>" with "/path/file.jpg" -> "'/path/file.jpg'"
+  (setq template (replace-regexp-in-string "\\(\<\<f\>\>\\)"
+                                           (format "'%s'" file)
+                                           template nil nil 1))
   (when post-process-template
     (setq template (funcall post-process-template template file)))
   template)

   "DWIM shell command" (read-shell-command "DWIM shell command: ")))

(cl-defun dwim-shell-command-execute-script (buffer-name script &key files extensions shell-util shell-args shell-pipe utils post-process-template on-completion)
  "Execute SCRIPT, with BUFFER-NAME."
  (cl-assert buffer-name nil "Script must have a buffer name")
  (cl-assert (not (string-empty-p script)) nil "Script must not be empty")
  (when (stringp extensions)

                                  (dwim-shell-command--command-reporter exec)
                                  (dwim-shell-command--command-on-completion exec))))

(defun dwim-shell-command--filter (process output)
  "Handles PROCESS filtering and STATE and OUTPUT."
  (when-let* ((exec (map-elt dwim-shell-command--commands (process-name process)))
              (reporter (dwim-shell-command--command-reporter exec)))
    (progress-reporter-update reporter))
  (comint-output-filter process output))

(cl-defun dwim-shell-command-on-marked-files (buffer-name script &key utils extensions shell-util shell-args shell-pipe post-process-template on-completion)
  "Execute SCRIPT, using BUFFER-NAME.
See `dwim-shell-command-execute-script' for all other params."
  (dwim-shell-command-execute-script buffer-name script
                                     :files (dwim-shell-command--marked-files)
                                     :utils utils
