|
![](/images/navbasebg.jpg) |
|
|
38.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 give you several ways to
specify which files to manipulate:
- 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.
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.
Here are the file-manipulating commands that operate on files in this
way. (Some other Dired commands, such as ! and the ‘%’
commands, also use these conventions to decide which files to work on.)
- 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.
If dired-copy-preserve-time is non-nil , then copying with
this command sets the modification time of the new file to be the same
as that of the old file.
The variable dired-recursive-copies controls whether
directories are copied recursively. The default is to not copy
recursively, which means that directories cannot be copied.
- D
- Delete the specified files (
dired-do-delete ). 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 ). The argument
new is the directory to rename into, or (if renaming a single
file) the new name.
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 ). 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 ).
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 ). This uses the chmod program, so
modespec can be any argument that chmod can handle.
- G newgroup <RET>
- Change the group of the specified files to newgroup
(
dired-do-chgrp ).
- 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-program specifies the name of the
program to use to do the work (different systems put chown in
different places).
- T timestamp <RET>
- Change the time of the specified files (
dired-do-touch ).
- 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-command and
lpr-switches (the same variables that lpr-buffer uses;
see Printing).
- Z
- Compress the specified files (
dired-do-compress ). If the file
appears to be a compressed file already, it is uncompressed instead.
- L
- Load the specified Emacs Lisp files (
dired-do-load ).
See Lisp Libraries.
- B
- Byte compile the specified Emacs Lisp files
(
dired-do-byte-compile ). See Byte Compilation.
- A regexp <RET>
- Search all the specified files for the regular expression regexp
(
dired-do-search ).
This command is a variant of tags-search . The search stops at
the first match it finds; use M-, to resume the search and find
the next match. See Tags Search.
- Q regexp <RET> to <RET>
- Perform
query-replace-regexp on each of the specified files,
replacing matches for regexp with the string
to (dired-do-query-replace-regexp ).
This command is a variant of tags-query-replace . If you exit the
query replace loop, you can use M-, to resume the scan and replace
more matches. See Tags Search.
One special file-operation command is +
(dired-create-directory ). This command reads a directory name and
creates the directory if it does not already exist.
|
|
|