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.
“dired” is short for Directory Edit. It is a old term for file management.
To start viewing directory, called dired 【Ctrl+x d】. Or, use the menu 〖File ▸ Open Directory…〗.
Here's a list of common basic commands:
| Key | Purpose |
|---|---|
| 【Enter ↵】 | Open the file |
| 【q】 | Close the dir |
| 【C】 | Copy file |
| 【R】 | Rename file |
| 【D】 | Delete file |
| 【+】 | create a new dir |
| 【Z】 | compress/decompress the file by gzip |
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:
| Key | Purpose |
|---|---|
| 【m】 | mark a file |
| 【u】 | unmark |
| 【U】 | unmark all marked |
| 【% m】 | mark by pattern (regex) |
For example, if you want to mark all HTML files, type 【% .】, then type \.html$.
Here are other common dired commands:
| Key | Purpose |
|---|---|
| 【g】 | refresh dir listing |
| 【^】 | go to parent dir |
dired is often used in combination with shell-command 【Alt+!】. For example, suppose you downloaded a program and is going thru the install process of {gunzip, untar, configure, make, sudo make install}. You can run these command inside emacs by calling shell, or you can just execute them one at a time by calling shell-command 【Alt+!】. 〔☛ Emacs Shell Tutorial (Bash, cmd.exe, PowerShell)〕
When you are in dired mode, there are 3 new graphical menus: {〖Operate〗, 〖Mark〗, 〖Regex〗}. These menus lists the commands specific to dired. They are very useful as a cheatsheet. So, if you forgot what's the key to press to do something, look up in these menus.
See: Emacs: Rename Files Interactively by Pattern (regex; wdired).
For more dired tips, see: