30.7 Operating on Files
This section describes the basic Dired commands to operate on one file or several files. All of these commands are capital letters; all of them use the minibuffer, either to read an argument or to ask for confirmation, before they act. All of them let you specify the files to manipulate in these ways:
- If you give the command a numeric prefix argument n, it operates on the next n files, starting with the current file. (If n is negative, the command operates on the −n files preceding the current line.)
- Otherwise, if some files are marked with ‘*’, the command operates on all those files.
- Otherwise, the command operates on the current file only.
Certain other Dired commands, such as ! and the ‘%’ commands, use the same conventions to decide which files to work on.
Commands which ask for a destination directory, such as those which copy and rename files or create links for them, try to guess the default target directory for the operation. Normally, they suggest the Dired buffer’s default directory, but if the variable
dired-dwim-target is non-
nil, and if there is another Dired buffer displayed in the next window, that other buffer’s directory is suggested instead.
- C new <RET>
- Copy the specified files (
dired-do-copy). The argument new is the directory to copy into, or (if copying a single file) the new name. This is like the shell command
nil, then copying with this command preserves the modification time of the old file in the copy, like ‘cp -p’.
- Delete the specified files (
dired-do-delete). This is like the shell command
rm.Like the other commands in this section, this command operates on the marked files, or the next n files. By contrast, x (
dired-do-flagged-delete) deletes all flagged files.
- R new <RET>
- Rename the specified files (
dired-do-rename). If you rename a single file, the argument new is the new name of the file. If you rename several files, the argument new is the directory into which to move the files (this is like the shell command mv).Dired automatically changes the visited file name of buffers associated with renamed files so that they refer to the new names.
- H new <RET>
- Make hard links to the specified files (
dired-do-hardlink). This is like the shell command ln. The argument new is the directory to make the links in, or (if making just one link) the name to give the link.
- S new <RET>
- Make symbolic links to the specified files (
dired-do-symlink). This is like ‘ln -s’. The argument new is the directory to make the links in, or (if making just one link) the name to give the link.
- M modespec <RET>
- Change the mode (also called permission bits) of the specified files (
dired-do-chmod). modespec can be in octal or symbolic notation, like arguments handled by the chmodprogram.
- G newgroup <RET>
- Change the group of the specified files to newgroup (
- O newowner <RET>
- Change the owner of the specified files to newowner (
dired-do-chown). (On most systems, only the superuser can do this.)The variable
dired-chown-programspecifies the name of the program to use to do the work (different systems put chown in different places).
- T timestamp <RET>
- Touch the specified files (
dired-do-touch). This means updating their modification times to the present time. This is like the shell command
- P command <RET>
- Print the specified files (
dired-do-print). You must specify the command to print them with, but the minibuffer starts out with a suitable guess made using the variables
lpr-switches(the same variables that
lpr-bufferuses; see Printing).
- Compress the specified files (
dired-do-compress). If the file appears to be a compressed file already, uncompress it instead. Each marked file is compressed into its own archive.
- Compress the specified files (
dired-do-compress-to) into a single archive anywhere on the file system. The compression algorithm is determined by the extension of the archive, see
- Decrypt the specified files (
epa-dired-do-decrypt). See Dired integration.
- Verify digital signatures on the specified files (
epa-dired-do-verify). See Dired integration.
- Digitally sign the specified files (
epa-dired-do-sign). See Dired integration.
- Encrypt the specified files (
epa-dired-do-encrypt). See Dired integration.
- Load the specified Emacs Lisp files (
dired-do-load). See Lisp Libraries.
- Byte compile the specified Emacs Lisp files (
dired-do-byte-compile). See Byte Compilation.