The file system groups files into directories. A directory listing is a list of all the files in a directory. Emacs provides commands to create and delete directories, and to make directory listings in brief format (file names only) and verbose format (sizes, dates, and authors included). Emacs also includes a directory browser feature called Dired; see Dired.
Display a brief directory listing (
Display a verbose directory listing.
Create a new directory named dirname.
Delete the directory named dirname. If it isn’t empty, you will be asked whether you want to delete it recursively.
The command to display a directory listing is C-x C-d
list-directory). It reads using the minibuffer a file name
which is either a directory to be listed or a wildcard-containing
pattern for the files to be listed. For example,
C-x C-d /u2/emacs/etc RET
lists all the files in directory /u2/emacs/etc. Here is an example of specifying a file name pattern:
C-x C-d /u2/emacs/src/*.c RET
Normally, C-x C-d displays a brief directory listing containing just file names. A numeric argument (regardless of value) tells it to make a verbose listing including sizes, dates, and owners (like ‘ls -l’).
The text of a directory listing is mostly obtained by running
ls in an inferior process. Two Emacs variables control the
switches passed to
ls: list-directory-brief-switches is
a string giving the switches to use in brief listings (
default), and list-directory-verbose-switches is a string
giving the switches to use in a verbose listing (
In verbose directory listings, Emacs adds information about the amount of free space on the disk that contains the directory. To do this, it runs the program specified by directory-free-space-program with arguments directory-free-space-args.
The command M-x delete-directory prompts for a directory name using the minibuffer, and deletes the directory if it is empty. If the directory is not empty, you will be asked whether you want to delete it recursively. On systems that have a “Trash” (or “Recycle Bin”) feature, you can make this command move the specified directory to the Trash instead of deleting it outright, by changing the variable delete-by-moving-to-trash to t. See Misc File Ops, for more information about using the Trash.