Function: dired-do-compress-to
dired-do-compress-to is an autoloaded, interactive and byte-compiled
function defined in dired-aux.el.gz.
Signature
(dired-do-compress-to)
Documentation
Compress selected files and directories to an archive.
Prompt for the archive file name.
Choose the archiving command based on the archive file-name extension
and dired-compress-files-alist.
Probably introduced at or before Emacs version 25.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/dired-aux.el.gz
;;;###autoload
(defun dired-do-compress-to ()
"Compress selected files and directories to an archive.
Prompt for the archive file name.
Choose the archiving command based on the archive file-name extension
and `dired-compress-files-alist'."
(interactive)
(let* ((in-files (dired-get-marked-files nil nil nil nil t))
(out-file (expand-file-name (read-file-name "Compress to: ")))
(rule (cl-find-if
(lambda (x)
(string-match (car x) out-file))
dired-compress-files-alist)))
(cond ((not rule)
(error
"No compression rule found for %s, see `dired-compress-files-alist'"
out-file))
((and (file-exists-p out-file)
(not (y-or-n-p
(format "%s exists, overwrite?"
(abbreviate-file-name out-file)))))
(message "Compression aborted"))
(t
(when (zerop
(dired-shell-command
(format-spec (cdr rule)
`((?o . ,(shell-quote-argument
(file-local-name out-file)))
(?i . ,(mapconcat
(lambda (in-file)
(shell-quote-argument
(file-relative-name in-file)))
in-files " "))))))
(message (ngettext "Compressed %d file to %s"
"Compressed %d files to %s"
(length in-files))
(length in-files)
(file-name-nondirectory out-file)))))))