Emacs: File Manager, dired

By Xah Lee. Date: . Last updated: .

Emacs is a excellent tool for file management. For example, list files, copy/delete, rename, moving files, create/delete directory. Once you become familiar with it, you almost never go to shell or the Operating System file manager for these tasks.

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

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
Done. Display last buffer. (call kill-buffer if you actually want to close it.)
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

Note: you can have copy command automatically select the target dir in a split pane. Use (setq dired-dwim-target t). [see Emacs: Dired Customization]

Mark/Unmark Multiple Files

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: Regex Tutorial]
For example, if you want to mark all HTML files, type % m, then type html$.

Dired Navigation

Here are other common dired commands:

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

Dired Customization

Emacs: Dired Customization

Put $5 at https://www.patreon.com/xahlee , or goto paypal.com and pay to Xah@XahLee.org . Message me on XahLee discord, say so, ask me questions.
Or 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 Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc