[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired commands to operate on the files listed.
The Dired buffer is "read-only," and inserting text in it is not useful, so ordinary printing characters such as d and x are redefined for special Dired commands. Some Dired commands mark or flag the current file (that is, the file on the current line); other commands operate on the marked files or on the flagged files. You first mark certain files in order to operate on all of them with on command.
The Dired-X package provides various extra features for Dired mode. See Dired-X: (dired-x)Top section `Top' in Dired Extra Version 2 User's Manual.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To invoke Dired, do C-x d or M-x dired. The command
reads a directory name or wildcard file name pattern as a minibuffer
argument to specify the files to list. C-x C-f given a
directory name also invokes Dired. Where dired
differs from
list-directory
is that it puts the buffer into Dired mode, so
that the special commands of Dired are available.
The variable dired-listing-switches
specifies the options to
give to ls
for listing the directory; this string must
contain `-l'. If you use a numeric prefix argument with the
dired
command, you can specify the ls
switches with the
minibuffer before you enter the directory specification. No matter
how they are specified, the ls
switches can include short
options (that is, single characters) requiring no arguments, and long
options (starting with `--') whose arguments are specified with
`='.
On MS-Windows and MS-DOS systems, Emacs emulates ls
;
see Emulation of ls
on MS-Windows, for options and peculiarities of that emulation.
To display the Dired buffer in another window rather than in the
selected window, use C-x 4 d (dired-other-window
) instead
of C-x d. C-x 5 d (dired-other-frame
) uses a
separate frame to display the Dired buffer.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
All the usual Emacs cursor motion commands are available in Dired buffers. The keys C-n and C-p are redefined to put the cursor at the beginning of the file name on the line, rather than at the beginning of the line.
For extra convenience, SPC and n in Dired are equivalent to C-n. p is equivalent to C-p. (Moving by lines is so common in Dired that it deserves to be easy to type.) DEL (move up and unflag) is often useful simply for moving up.
j (dired-goto-file
) moves point to the line that
describes a specified file or directory.
Some additional navigation commands are available when the Dired buffer includes several directories. See section Moving Over Subdirectories.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
One of the most frequent uses of Dired is to first flag files for deletion, then delete the files that were flagged.
Flag this file for deletion.
Remove deletion flag on this line.
Move point to previous line and remove the deletion flag on that line.
Delete the files that are flagged for deletion.
You can flag a file for deletion by moving to the line describing
the file and typing d (dired-flag-file-deletion
). The
deletion flag is visible as a `D' at the beginning of the line.
This command moves point to the next line, so that repeated d
commands flag successive files. A numeric argument serves as a repeat
count.
The reason for flagging files for deletion, rather than deleting
files immediately, is to reduce the danger of deleting a file
accidentally. Until you direct Dired to delete the flagged files, you
can remove deletion flags using the commands u and DEL.
u (dired-unmark
) works just like d, but removes
flags rather than making flags. DEL
(dired-unmark-backward
) moves upward, removing flags; it is
like u with argument -1.
To delete the flagged files, type x
(dired-do-flagged-delete
). (This is also known as
expunging.) This command first displays a list of all the file
names flagged for deletion, and requests confirmation with yes.
If you confirm, Dired deletes the flagged files, then deletes their
lines from the text of the Dired buffer. The Dired buffer, with
somewhat fewer lines, remains selected.
If you answer no or quit with C-g when asked to confirm, you return immediately to Dired, with the deletion flags still present in the buffer, and no files actually deleted.
You can delete empty directories just like other files, but normally
Dired cannot delete directories that are nonempty. If the variable
dired-recursive-deletes
is non-nil
, then Dired can
delete nonempty directories including all their contents. That can
be somewhat risky.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Flag all auto-save files (files whose names start and end with `#') for deletion (see section Auto-Saving: Protection Against Disasters).
Flag all backup files (files whose names end with `~') for deletion (see section Backup Files).
Flag for deletion all files with certain kinds of names which suggest you could easily create those files again.
Flag excess numeric backup files for deletion. The oldest and newest few backup files of any one file are exempt; the middle ones are flagged.
Flag for deletion all files whose names match the regular expression regexp.
The #, ~, &, and . commands flag many files for deletion, based on their file names. These commands are useful precisely because they do not themselves delete any files; you can remove the deletion flags from any flagged files that you really wish to keep.
& (dired-flag-garbage-files
) flags files whose names
match the regular expression specified by the variable
dired-garbage-files-regexp
. By default, this matches certain
files produced by TeX, `.bak' files, and the `.orig' and
`.rej' files produced by patch
.
# (dired-flag-auto-save-files
) flags for deletion all
files whose names look like auto-save files--that is, files whose
names begin and end with `#'. See section Auto-Saving: Protection Against Disasters.
~ (dired-flag-backup-files
) flags for deletion all
files whose names say they are backup files--that is, files whose
names end in `~'. See section Backup Files.
. (period, dired-clean-directory
) flags just some of the
backup files for deletion: all but the oldest few and newest few backups
of any one file. Normally dired-kept-versions
(not
kept-new-versions
; that applies only when saving) specifies the
number of newest versions of each file to keep, and
kept-old-versions
specifies the number of oldest versions to
keep.
Period with a positive numeric argument, as in C-u 3 .,
specifies the number of newest versions to keep, overriding
dired-kept-versions
. A negative numeric argument overrides
kept-old-versions
, using minus the value of the argument to
specify the number of oldest versions of each file to keep.
The % d command flags all files whose names match a specified
regular expression (dired-flag-files-regexp
). Only the
non-directory part of the file name is used in matching. You can use
`^' and `$' to anchor matches. You can exclude certain
subdirectories from marking by hiding them while you use % d.
See section Hiding Subdirectories.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are several Dired commands for visiting or examining the files listed in the Dired buffer. All of them apply to the current line's file; if that file is really a directory, these commands invoke Dired on that subdirectory (making a separate Dired buffer).
Visit the file described on the current line, like typing C-x C-f
and supplying that file name (dired-find-file
). See section Visiting Files.
Equivalent to f.
Like f, but uses another window to display the file's buffer
(dired-find-file-other-window
). The Dired buffer remains visible
in the first window. This is like using C-x 4 C-f to visit the
file. See section Multiple Windows.
Visit the file described on the current line, and display the buffer in
another window, but do not select that window (dired-display-file
).
Visit the file named by the line you click on
(dired-mouse-find-file-other-window
). This uses another window
to display the file, like the o command.
View the file described on the current line, using M-x view-file
(dired-view-file
). Viewing a file with view-file
is
like visiting it, but is slanted toward moving around in the file
conveniently and does not allow changing the file. See section Miscellaneous File Operations.
Visit the parent directory of the current directory
(dired-up-directory
). This is equivalent to moving to the line
for `..' and typing f there.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Instead of flagging a file with `D', you can mark the file with some other character (usually `*'). Most Dired commands to operate on files use the files marked with `*'. The only command that operates on flagged files is x, which expunges them.
Here are some commands for marking with `*', for unmarking, and for operating on marks. (See section Deleting Files with Dired, for commands to flag and unflag files.)
Mark the current file with `*' (dired-mark
). With a numeric
argument n, mark the next n files starting with the current
file. (If n is negative, mark the previous -n
files.)
Mark all executable files with `*'
(dired-mark-executables
). With a numeric argument, unmark all
those files.
Mark all symbolic links with `*' (dired-mark-symlinks
).
With a numeric argument, unmark all those files.
Mark with `*' all files which are directories, except for
`.' and `..' (dired-mark-directories
). With a numeric
argument, unmark all those files.
Mark all the files in the current subdirectory, aside from `.'
and `..' (dired-mark-subdir-files
).
Remove any mark on this line (dired-unmark
).
Move point to previous line and remove any mark on that line
(dired-unmark-backward
).
Remove all marks from all the files in this Dired buffer
(dired-unmark-all-marks
).
Remove all marks that use the character markchar
(dired-unmark-all-files
). The argument is a single
character--do not use RET to terminate it. See the description
of the * c command below, which lets you replace one mark
character with another.
With a numeric argument, this command queries about each marked file, asking whether to remove its mark. You can answer y meaning yes, n meaning no, or ! to remove the marks from the remaining files without asking about them.
Move down to the next marked file (dired-next-marked-file
)
A file is "marked" if it has any kind of mark.
Move up to the previous marked file (dired-prev-marked-file
)
Toggle all marks (dired-toggle-marks
): files marked with `*'
become unmarked, and unmarked files are marked with `*'. Files
marked in any other way are not affected.
Replace all marks that use the character old-markchar with marks
that use the character new-markchar (dired-change-marks
).
This command is the primary way to create or use marks other than
`*' or `D'. The arguments are single characters--do not use
RET to terminate them.
You can use almost any character as a mark character by means of this command, to distinguish various classes of files. If old-markchar is a space (` '), then the command operates on all unmarked files; if new-markchar is a space, then the command unmarks the files it acts on.
To illustrate the power of this command, here is how to put `D' flags on all the files that have no marks, while unflagging all those that already have `D' flags:
* c D t * c SPC D * c t SPC |
This assumes that no files were already marked with `t'.
Mark (with `*') all files whose names match the regular expression
regexp (dired-mark-files-regexp
). This command is like
% d, except that it marks files with `*' instead of flagging
with `D'.
Only the non-directory part of the file name is used in matching. Use `^' and `$' to anchor matches. You can exclude subdirectories by temporarily hiding them (see section Hiding Subdirectories).
Mark (with `*') all files whose contents contain a match for
the regular expression regexp
(dired-mark-files-containing-regexp
). This command is like
% m, except that it searches the file contents instead of the file
name.
Undo changes in the Dired buffer, such as adding or removing
marks (dired-undo
). This command does not revert the
actual file operations, nor recover lost files! It just undoes
changes in the buffer itself.
In some cases, using this after commands that operate on files can
cause trouble. For example, after renaming one or more files,
dired-undo
restores the original names in the Dired buffer,
which gets the Dired buffer out of sync with the actual contents of
the directory.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
Here are the file-manipulating Dired commands that operate on files.
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 cp
.
If dired-copy-preserve-time
is non-nil
, then copying
with this command preserves the modification time of the old file in
the copy, like `cp -p'.
The variable dired-recursive-copies
controls whether to copy
directories recursively (like `cp -r'). The default is
nil
, which means that directories cannot be copied.
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.
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.
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.
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.
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.
Change the group of the specified files to newgroup
(dired-do-chgrp
).
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).
Touch the specified files (dired-do-touch
). This means
updating their modification times to the present time. This is like
the shell command touch
.
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 section Printing Hard Copies).
Compress the specified files (dired-do-compress
). If the file
appears to be a compressed file already, uncompress it instead.
Load the specified Emacs Lisp files (dired-do-load
).
See section Libraries of Lisp Code for Emacs.
Byte compile the specified Emacs Lisp files
(dired-do-byte-compile
). See (elisp)Byte Compilation section `Byte Compilation' in The Emacs Lisp Reference Manual.
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 section Searching and Replacing with Tags Tables.
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 section Searching and Replacing with Tags Tables.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The Dired command ! (dired-do-shell-command
) reads a
shell command string in the minibuffer and runs that shell command on
all the specified files. (X is a synonym for !.) You can
specify the files to operate on in the usual ways for Dired commands
(see section Operating on Files).
The working directory for the shell command is the top-level directory of the Dired buffer.
There are two ways of applying a shell command to multiple files:
If you use `*' surrounded by whitespace in the shell command, then the command runs just once, with the list of file names substituted for the `*'. The order of file names is the order of appearance in the Dired buffer.
Thus, ! tar cf foo.tar * RET runs tar
on the entire
list of file names, putting them into one tar file `foo.tar'.
If you want to use `*' as a shell wildcard with whitespace around it, write `*""'. In the shell, this is equivalent to `*'; but since the `*' is not surrounded by whitespace, Dired does not treat it specially.
If the command string doesn't contain `*' surrounded by whitespace, then it runs once for each file. Normally the file name is added at the end.
For example, ! uudecode RET runs uudecode
on each
file.
However, if the command string contains `?' surrounded by whitespace, the current file name is substituted for `?' (rather than added at the end). You can use `?' this way more than once in the command, and the same file name replaces each occurrence.
To iterate over the file names in a more complicated fashion, use an explicit shell loop. For example, here is how to uuencode each file, making the output file name by appending `.uu' to the input file name:
for file in * ; do uuencode "$file" "$file" >"$file".uu; done |
The ! command does not attempt to update the Dired buffer to show new or modified files, because it doesn't understand shell commands, and does not know what files the shell command changed. Use the g command to update the Dired buffer (see section Updating the Dired Buffer).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes Dired commands which alter file names in a systematic way. Each command operates on some or all of the marked files, using a new name made by transforming the existing name.
Like the basic Dired file-manipulation commands (see section Operating on Files), the commands described here operate either on the next n files, or on all files marked with `*', or on the current file. (To mark files, use the commands described in Dired Marks vs. Flags.)
All of the commands described in this section work interactively: they ask you to confirm the operation for each candidate file. Thus, you can select more files than you actually need to operate on (e.g., with a regexp that matches many files), and then filter the selected names by typing y or n when the command prompts for confirmation.
Rename each of the selected files to an upper-case name
(dired-upcase
). If the old file names are `Foo'
and `bar', the new names are `FOO' and `BAR'.
Rename each of the selected files to a lower-case name
(dired-downcase
). If the old file names are `Foo' and
`bar', the new names are `foo' and `bar'.
These four commands rename, copy, make hard links and make soft links, in each case computing the new name by regular-expression substitution from the name of the old file.
The four regular-expression substitution commands effectively
perform a search-and-replace on the selected file names. They read
two arguments: a regular expression from, and a substitution
pattern to; they match each "old" file name against
from, and then replace the matching part with to. You can
use `\&' and `\digit' in to to refer to all or
part of what the pattern matched in the old file name, as in
replace-regexp
(see section Regexp Replacement). If the regular
expression matches more than once in a file name, only the first match
is replaced.
For example, % R ^.*$ RET x-\& RET renames each selected file by prepending `x-' to its name. The inverse of this, removing `x-' from the front of each file name, is also possible: one method is % R ^x-\(.*\)$ RET \1 RET; another is % R ^x- RET RET. (Use `^' and `$' to anchor matches that should span the whole file name.)
Normally, the replacement process does not consider the files' directory names; it operates on the file name within the directory. If you specify a numeric argument of zero, then replacement affects the entire absolute file name including directory name. (A non-zero argument specifies the number of files to operate on.)
You may want to select the set of files to operate on using the same regexp from that you will use to operate on them. To do this, mark those files with % m from RET, then use the same regular expression in the command to operate on the files. To make this more convenient, the % commands to operate on files use the last regular expression specified in any % command as a default.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here are two Dired commands that compare specified files using
diff
. They show the output in a buffer using Diff mode
(see section Comparing Files).
Compare the current file (the file at point) with another file (the
file at the mark) using the diff
program (dired-diff
).
The file at the mark is the first argument of diff
, and the
file at point is the second argument. This refers to the ordinary
Emacs mark, not Dired marks; use C-SPC
(set-mark-command
) to set the mark at the first file's line
(see section Setting the Mark).
Compare the current file with its latest backup file
(dired-backup-diff
). If the current file is itself a backup,
compare it with the file it is a backup of; this way, you can compare
a file with any one of its backups.
The backup file is the first file given to diff
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A Dired buffer displays just one directory in the normal case; but you can optionally include its subdirectories as well.
The simplest way to include multiple directories in one Dired buffer is
to specify the options `-lR' for running ls
. (If you give a
numeric argument when you run Dired, then you can specify these options
in the minibuffer.) That produces a recursive directory listing showing
all subdirectories at all levels.
More often, you will want to show only specific subdirectories. You can do this with the i command:
Insert the contents of a subdirectory later in the buffer.
Use the i (dired-maybe-insert-subdir
) command on a line
that describes a file which is a directory. It inserts the contents of
that directory into the same Dired buffer, and moves there. Inserted
subdirectory contents follow the top-level directory of the Dired
buffer, just as they do in `ls -lR' output.
If the subdirectory's contents are already present in the buffer, the i command just moves to it.
In either case, i sets the Emacs mark before moving, so C-u C-SPC takes you back to the old position in the buffer (the line describing that subdirectory).
Use the l command (dired-do-redisplay
) to update the
subdirectory's contents. Use C-u k on the subdirectory header
line to delete the subdirectory. See section Updating the Dired Buffer.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
You can insert subdirectories with specified ls
switches in
Dired buffers, using C-u i. You can change the ls
switches of an already inserted subdirectory using C-u l.
In Emacs versions 22.1 and later, Dired remembers the switches, so that reverting the buffer will not change them back to the main directory's switches. Deleting a subdirectory forgets about its switches.
Using dired-undo
(usually bound to C-_ and C-x u)
to reinsert or delete subdirectories, that were inserted with explicit
switches, can bypass Dired's machinery for remembering (or forgetting)
switches. Deleting a subdirectory using dired-undo
does not
forget its switches. When later reinserted using i, it will be
reinserted using its old switches. Using dired-undo
to
reinsert a subdirectory that was deleted using the regular
Dired commands (not dired-undo
) will originally insert it with
its old switches. However, reverting the buffer will relist it using
the buffer's default switches. If any of this yields problems, you
can easily correct the situation using C-u i or C-u l.
Dired does not remember the R
switch. Inserting a subdirectory
with switches that include the R
switch is equivalent with
inserting each of its subdirectories using all remaining switches.
For instance, updating or killing a subdirectory that was inserted
with the R
switch will not update or kill its subdirectories.
The buffer's default switches do not affect subdirectories that were inserted using explicitly specified switches. In particular, commands such as s, that change the buffer's switches do not affect such subdirectories. (They do affect subdirectories without explicitly assigned switches, however.)
You can make Dired forget about all subdirectory switches and relist all subdirectories with the buffer's default switches using M-x dired-reset-subdir-switches. This also reverts the Dired buffer.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When a Dired buffer lists subdirectories, you can use the page motion commands C-x [ and C-x ] to move by entire directories (see section Pages).
The following commands move across, up and down in the tree of directories within one Dired buffer. They move to directory header lines, which are the lines that give a directory's name, at the beginning of the directory's contents.
Go to next subdirectory header line, regardless of level
(dired-next-subdir
).
Go to previous subdirectory header line, regardless of level
(dired-prev-subdir
).
Go up to the parent directory's header line (dired-tree-up
).
Go down in the directory tree, to the first subdirectory's header line
(dired-tree-down
).
Move up to the previous directory-file line (dired-prev-dirline
).
These lines are the ones that describe a directory as a file in its
parent directory.
Move down to the next directory-file line (dired-prev-dirline
).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Hiding a subdirectory means to make it invisible, except for its header line.
Hide or reveal the subdirectory that point is in, and move point to the
next subdirectory (dired-hide-subdir
). A numeric argument serves
as a repeat count.
Hide all subdirectories in this Dired buffer, leaving only their header
lines (dired-hide-all
). Or, if any subdirectory is currently
hidden, make all subdirectories visible again. You can use this command
to get an overview in very deep directory trees or to move quickly to
subdirectories far away.
Ordinary Dired commands never consider files inside a hidden subdirectory. For example, the commands to operate on marked files ignore files in hidden directories even if they are marked. Thus you can use hiding to temporarily exclude subdirectories from operations without having to remove the Dired marks on files in those subdirectories.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes commands to update the Dired buffer to reflect outside (non-Dired) changes in the directories and files, and to delete part of the Dired buffer.
Update the entire contents of the Dired buffer (revert-buffer
).
Update the specified files (dired-do-redisplay
). You specify the
files for l in the same way as for file operations.
Delete the specified file lines--not the files, just the lines
(dired-do-kill-lines
).
Toggle between alphabetical order and date/time order
(dired-sort-toggle-or-edit
).
Refresh the Dired buffer using switches as
dired-listing-switches
.
Type g (revert-buffer
) to update the contents of the
Dired buffer, based on changes in the files and directories listed.
This preserves all marks except for those on files that have vanished.
Hidden subdirectories are updated but remain hidden.
To update only some of the files, type l
(dired-do-redisplay
). Like the Dired file-operating commands,
this command operates on the next n files (or previous
-n files), or on the marked files if any, or on the
current file. Updating the files means reading their current status,
then updating their lines in the buffer to indicate that status.
If you use l on a subdirectory header line, it updates the contents of the corresponding subdirectory.
To delete the specified file lines from the buffer--not
delete the files--type k (dired-do-kill-lines
). Like
the file-operating commands, this command operates on the next n
files, or on the marked files if any; but it does not operate on the
current file as a last resort.
If you use k with a numeric prefix argument to kill the line for a file that is a directory, which you have inserted in the Dired buffer as a subdirectory, it deletes that subdirectory from the buffer as well. Typing C-u k on the header line for a subdirectory also deletes the subdirectory from the Dired buffer.
The g command brings back any individual lines that you have killed in this way, but not subdirectories--you must use i to reinsert a subdirectory.
The files in a Dired buffers are normally listed in alphabetical order
by file names. Alternatively Dired can sort them by date/time. The
Dired command s (dired-sort-toggle-or-edit
) switches
between these two sorting modes. The mode line in a Dired buffer
indicates which way it is currently sorted--by name, or by date.
C-u s switches RET lets you specify a new value for
dired-listing-switches
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
find
You can select a set of files for display in a Dired buffer more
flexibly by using the find
utility to choose the files.
To search for files with names matching a wildcard pattern use M-x find-name-dired. It reads arguments directory and pattern, and chooses all the files in directory or its subdirectories whose individual names match pattern.
The files thus chosen are displayed in a Dired buffer, in which the ordinary Dired commands are available.
If you want to test the contents of files, rather than their names,
use M-x find-grep-dired. This command reads two minibuffer
arguments, directory and regexp; it chooses all the files in
directory or its subdirectories that contain a match for
regexp. It works by running the programs find
and
grep
. See also M-x grep-find, in Searching with Grep under Emacs.
Remember to write the regular expression for grep
, not for Emacs.
(An alternative method of showing files whose contents match a given
regexp is the % g regexp command, see Dired Marks vs. Flags.)
The most general command in this series is M-x find-dired, which
lets you specify any condition that find
can test. It takes two
minibuffer arguments, directory and find-args; it runs
find
in directory, passing find-args to tell
find
what condition to test. To use this command, you need to
know how to use find
.
The format of listing produced by these commands is controlled by the
variable find-ls-option
, whose default value specifies using
options `-ld' for ls
. If your listings are corrupted, you
may need to change the value of this variable.
The command M-x locate provides a similar interface to the
locate
program. M-x locate-with-filter is similar, but
keeps only files whose names match a given regular expression.
These buffers don't work entirely like ordinary Dired buffers: file operations work, but do not always automatically update the buffer. Reverting the buffer with g deletes all inserted subdirectories, and erases all flags and marks.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Wdired is a special mode that allows you to perform file operations by editing the Dired buffer directly (the "W" in "Wdired" stands for "writable.") To enter Wdired mode, type M-x wdired-change-to-wdired-mode while in a Dired buffer. Alternatively, use `Edit File Names' in the `Immediate' menu bar menu.
While in Wdired mode, you can rename files by editing the file names
displayed in the Dired buffer. All the ordinary Emacs editing
commands, including rectangle operations and query-replace
, are
available for this. Once you are done editing, type C-c C-c
(wdired-finish-edit
). This applies your changes and switches
back to ordinary Dired mode.
Apart from simply renaming files, you can move a file to another directory by typing in the new file name (either absolute or relative). To mark a file for deletion, delete the entire file name. To change the target of a symbolic link, edit the link target name which appears next to the link name.
The rest of the text in the buffer, such as the file sizes and
modification dates, is marked read-only, so you can't edit it.
However, if you set wdired-allow-to-change-permissions
to
t
, you can edit the file permissions. For example, you can
change `-rw-r--r--' to `-rw-rw-rw-' to make a file
world-writable. These changes also take effect when you type C-c
C-c.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Image-Dired is a facility for browsing image files. It provides viewing the images either as thumbnails or in full size, either inside Emacs or through an external viewer.
To enter Image-Dired, mark the image files you want to look at in
the Dired buffer, using m as usual. Then type C-t d
(image-dired-display-thumbs
). This creates and switches to a
buffer containing image-dired, corresponding to the marked files.
You can also enter Image-Dired directly by typing M-x
image-dired. This prompts for a directory; specify one that has
image files. This creates thumbnails for all the images in that
directory, and displays them all in the "thumbnail buffer." This
takes a long time if the directory contains many image files, and it
asks for confirmation if the number of image files exceeds
image-dired-show-all-from-dir-max-files
.
With point in the thumbnail buffer, you can type RET
(image-dired-display-thumbnail-original-image
) to display a
sized version of it in another window. This sizes the image to fit
the window. Use the arrow keys to move around in the buffer. For
easy browsing, use SPC
(image-dired-display-next-thumbnail-original
) to advance and
display the next image. Typing DEL
(image-dired-display-previous-thumbnail-original
) backs up to
the previous thumbnail and displays that instead.
To view and the image in its original size, either provide a prefix
argument (C-u) before pressing RET, or type
C-RET (image-dired-thumbnail-display-external
) to
display the image in an external viewer. You must first configure
image-dired-external-viewer
.
You can delete images through Image-Dired also. Type d
(image-dired-flag-thumb-original-file
) to flag the image file
for deletion in the Dired buffer. You can also delete the thumbnail
image from the thumbnail buffer with C-d
(image-dired-delete-char
).
More advanced features include image tags, which are metadata
used to categorize image files. The tags are stored in a plain text
file configured by image-dired-db-file
.
To tag image files, mark them in the dired buffer (you can also mark
files in Dired from the thumbnail buffer by typing m) and type
C-t t (image-dired-tag-files
). You will be prompted for
a tag. To mark files having a certain tag, type C-t f
(image-dired-mark-tagged-files
). After marking image files
with a certain tag, you can use C-t d to view them.
You can also tag a file directly from the thumbnail buffer by typing
t t and you can remove a tag by typing t r. There is also
a special "tag" called "comment" for each file (it is not a tag in
the exact same sense as the other tags, it is handled slightly
different). That is used to enter a comment or description about the
image. You comment a file from the thumbnail buffer by typing
c. You will be prompted for a comment. Type C-t c to add
a comment from Dired (image-dired-dired-comment-files
).
Image-Dired also provides simple image manipulation. In the thumbnail buffer, type L to rotate the original image 90 degrees anti clockwise, and R to rotate it 90 degrees clockwise. This rotation is lossless, and uses an external utility called JpegTRAN.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An unusual Dired file-operation command is +
(dired-create-directory
). This command reads a directory name,
and creates the directory if it does not already exist.
The w command (dired-copy-filename-as-kill
) puts the
names of the marked (or next n) files into the kill ring, as if
you had killed them with C-w. The names are separated by a space.
With a zero prefix argument, this uses the absolute file name of each marked file. With just C-u as the prefix argument, it uses file names relative to the Dired buffer's default directory. (This can still contain slashes if in a subdirectory.) As a special case, if point is on a directory headerline, w gives you the absolute name of that directory. Any prefix argument or marked files are ignored in this case.
The main purpose of this command is so that you can yank the file names into arguments for other Emacs commands. It also displays what it added to the kill ring, so you can use it to display the list of currently marked files in the echo area.
The command M-x dired-compare-directories is used to compare the current Dired buffer with another directory. It marks all the files that are "different" between the two directories. It puts these marks in all Dired buffers where these files are listed, which of course includes the current buffer.
The default comparison method (used if you type RET at the
prompt) is to compare just the file names--each file name that does
not appear in the other directory is "different." You can specify
more stringent comparisons by entering a Lisp expression, which can
refer to the variables size1
and size2
, the respective
file sizes; mtime1
and mtime2
, the last modification
times in seconds, as floating point numbers; and fa1
and
fa2
, the respective file attribute lists (as returned by the
function file-attributes
). This expression is evaluated for
each pair of like-named files, and if the expression's value is
non-nil
, those files are considered "different."
For instance, the sequence M-x dired-compare-directories
RET (> mtime1 mtime2) RET
marks files newer in this
directory than in the other, and marks files older in the other
directory than in this one. It also marks files with no counterpart,
in both directories, as always.
On the X window system, Emacs supports the "drag and drop" protocol. You can drag a file object from another program, and drop it onto a Dired buffer; this either moves, copies, or creates a link to the file in that directory. Precisely which action is taken is determined by the originating program. Dragging files out of a Dired buffer is currently not supported.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Mark Kaminski on July, 3 2008 using texi2html 1.70.