(emacs.info) Shell Commands in Dired
Info Catalog
(emacs.info) Operating on Files
(emacs.info) Dired
(emacs.info) Transforming File Names
Shell Commands in Dired
=======================
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. You can specify the files to operate on in the usual
ways for Dired commands ( Operating on Files). There are two
ways of applying a shell command to multiple files:
* If you use `*' in the shell command, then it 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 the command string doesn't contain `*', then it runs once _for
each file_, with the file name added at the end.
For example, `! uudecode <RET>' runs `uudecode' on each file.
What if you want to run the shell command once for each file but with
the file name inserted in the middle? Or if you want to use the file
names in a more complicated fashion? Use a shell loop. For example,
this shell command would run `uuencode' on each of the specified files,
writing the output into a corresponding `.uu' file:
for file in *; do uuencode $file $file >$file.uu; done
The working directory for the shell command is the top-level
directory of the Dired buffer.
The `!' command does not attempt to update the Dired buffer to show
new or modified files, because it doesn't really understand shell
commands, and does not know what files the shell command changed. Use
the `g' command to update the Dired buffer ( Dired Updating).
Info Catalog
(emacs.info) Operating on Files
(emacs.info) Dired
(emacs.info) Transforming File Names
automatically generated by
info2html