Книга: Learning GNU Emacs, 3rd Edition
5.2.6.5 Operating on groups of files
5.2.6.5 Operating on groups of files
In the course of daily work, a directory can get cluttered with many different kinds of files. Eventually, you need to make subdirectories to organize the files by project, then move the files to those subdirectories. You can do both these things from within Dired.
Let's say that the ch files are chapters from a novel you work on in your spare time. We need a subdirectory called novel to store the files in. You can create a directory by typing + (for dired-create-directory).
Type: +
Emacs asks for a directory name (Windows).
Type: novel Enter
Emacs creates the directory and displays it on the screen (Windows).
Now let's move the ch files we marked into the new directory. We'll use the rename command, R. This command, like the Unix mv command, is used for renaming files and for moving them. Because we have marked more than one file with an asterisk, when we type R, Emacs assumes we mean to move the marked files.
Type: R
Emacs asks where you want to move the marked files to (Windows).
Type: novel Enter
Emacs moves the files (Windows).
Now you can see that the files have moved. Marking files by regular expression allows you to work with a select group of files quickly.
One of the more interesting things you can do with a group of files is perform a query-replace on all of them with a single command. On large projects, a last-minute change often forces arduous searching and replacing of certain text in each file. First, select the files you want to include in the query-replace, then press Q (for dired-do-query-replace). Put in the search string, then the replacement string (the strings can be plain text or a regular expression) and Emacs starts a query-replace that moves you through each file sequentially. Here's the only hitch: if you interrupt the query-replace with a recursive edit, you can't restart it without going back to the Dired buffer.
Another interesting command is searching across files for a given regular expression. To do this, mark the files, then press A. Emacs stops at the first match; press M-, to move to the next match.
- 9.1.4. Kernel Abstractions
- 5.2.6.4 Using regular expressions to choose files
- 5.2.6 Working with Groups of Files
- 5.2.6.3 Selecting files by type
- Для чего нужны папки Windows, Documents and Settings, Program Files и Temp?
- Можно ли указать использование по умолчанию вместо C:Program Files другого каталога для установки программ?
- Можно ли удалять из папки Program Files папки деинсталлированных программ?
- Use and Edit Files in the
- Абстрактный базовый класс FileSystemInfo
- Класс FileStream и байтовый ввод-вывод в файл
- Managing Files with the Shell
- Working with Compressed Files