Emacs: File Management (dired tutorial)

Buy Xah Emacs Tutorial. Master emacs benefits for life.
, , …,

Emacs is a excellent tool for file management. For example, listing files, copy/delete files, rename files, moving files, creating/deleting directory. Once you become familiar with it, you almost never go back to shell or the OS desktop for these tasks.

emacs dired
A Screenshot of emacs's feature for file management.

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

{Copy, Delete, Rename} File

To start viewing directory, called dired.

Here's a list of basic commands:

Enter ↵Open the file
qClose the dir
CCopy file
RRename/move file
DDelete file
+create a new dir
Zcompress/decompress the file by gzip
the Operate menu in Emacs's dired mode
Emacs's dired mode's Operate menu.

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.

To mark a file, press m. Here's a list of basic marking commands:

mmark a file
Uunmark all marked
% mmark by pattern (regex)

For example, if you want to mark all HTML files, type 【% m】, then type \.html$.

Dired Navigation

Here are other common dired commands:

grefresh dir listing
^go to parent dir

dired is often used in together with shell-commandAlt+!】 or shell. 〔➤ Emacs: Run Shell in Emacs

For complete list of dired commands, call describe-mode.

(info "(emacs) Dired")

Renaming Many Files

See: Emacs: Rename Files Interactively.

Advanced Dired Tips & Settings

For more dired tips, see:

Open File (PDF, image, …) in External App

Emacs Lisp: Open File in External App

Like it? Buy Xah Emacs Tutorial.
blog comments powered by Disqus