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://ergoemacs.org/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))))))

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys

ELisp

ELisp Examples

ELisp Write Major Mode


Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Doc

Working with Brackets

Power Editing

Org Mode

HTML

Emacs Efficiency

Misc