Emacs: Zip Dir in Dired

By Xah Lee. Date: .
(defun xah-dired-to-zip ()
  "Zip the current file in `dired'.
If multiple files are marked, only zip the first one.
Require unix zip command line tool.
URL `http://xahlee.info/emacs/emacs/emacs_dired_zip_dir.html'
Version 2021-01-14"
  (interactive)
  (let ( (fName (elt (dired-get-marked-files) 0)))
    (shell-command
     (format
      "zip -r %s %s"
      (shell-quote-argument (concat (file-relative-name fName) ".zip"))
      (shell-quote-argument (file-relative-name fName))))))
ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Font

Split Window

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc