Emacs: File Manager, dired

By Xah Lee. Date: . Last updated: .

What is Dired

Emacs is a excellent tool for file management. e.g. list files, copy, delete, rename, move, or create, delete directory.

“dired” is short for Directory Edit. It is a old term for file management.

Start Dired

To start viewing directory, Alt+x dired.

When in dired, most commands have a single letter key.

emacs dired menu 2021-07-19
emacs dired

Copy, Delete, Rename File

Here's the most useful commands:

dired-find-fileEnter
Open the file or directory.
quit-windowq
hide the dired buffer. (when you are done) Display last buffer.
dired-do-copyC
Copy file
dired-do-renameR
Rename/move file
dired-do-deleteD
Delete file or directory
dired-create-directory+
Create new dir
dired-do-compressZ
Compress/decompress the file by gzip

Mark Files for an Operation

Sometimes you want to copy or delete many files. You can mark the files, then apply a command on all marked files.

dired mark menu 2021-07-19
dired mark menu

Here's basic marking commands:

dired-markm
Mark a file
dired-unmarku
Unmark
dired-unmark-all-marksU
Unmark all marked
dired-mark-files-regexp% m
Mark by regex. [see Emacs: Regular Expression]
For example, if you want to mark all HTML files, type % m, then type html$.

Dir Navigation

revert-bufferg
Refresh dir listing
dired-up-directory^
Go to parent dir
dired-next-dirline>
Move cursor to next subdirectory.
dired-prev-dirline<
Move cursor to previous subdirectory.

Shell Command on File

dired-do-shell-command!
Prompt a shell command to run on the file the cursor is on.

Dired Help

When in dired, Alt+x describe-mode

Emacs Dired, File Management

Emacs, File and Buffer