Previous: , Up: Files   [Contents][Index]

14.10 Miscellaneous File Operations

Emacs has commands for performing many other operations on files. All operate on one file; they do not accept wildcard file names.

You can use the command M-x add-name-to-file to add a name to an existing file without removing the old name. The new name must belong on the file system that the file is on.

M-x append-to-file adds the text of the region to the end of the specified file.

M-x copy-file reads the file old and writes a new file named new with the same contents. Confirmation is required if a file named new already exists, because copying overwrites the old contents of the file new.

M-x delete-file deletes a specified file, like the rm command in the shell. If you are deleting many files in one directory, it may be more convenient to use Dired (see Dired).

M-x insert-file inserts a copy of the contents of a specified file into the current buffer at point, leaving point unchanged before the contents and the mark after them. See Mark.

M-x make-symbolic-link reads two file names old and linkname, and then creates a symbolic link named linkname and pointing at old. Future attempts to open file linkname will then refer to the file named old at the time the opening is done, or will result in an error if the name old is not in use at that time. Confirmation is required if you create the link while linkname is in use. Note that not all systems support symbolic links.

M-x rename-file reads two file names old and new using the minibuffer, then renames file old as new. If a file named new already exists, you must confirm with yes or renaming is not done; this is because renaming causes the previous meaning of the name new to be lost. If old and new are on different file systems, the file old is copied and deleted.

M-x view-file allows you to scan or read a file by sequential screenfuls. It reads a file name argument using the minibuffer. After reading the file into an Emacs buffer, view-file reads and displays one windowful. You can then type SPC to scroll forward one window, or DEL to scroll backward. Various other commands are provided for moving around in the file, but none for changing it; type C-h while viewing a file for a list of them. Most commands are the default Emacs cursor motion commands. To exit from viewing, type C-c.

Previous: , Up: Files   [Contents][Index]