If I have a group of files with a .htm extention, how can I rename them all to .html?
mv *.htm *.html
does not work.
|
feedback
|
|
Or, you could use pure bash... (except for mv, that is..)
and avoid the nasty basename stuff. ;) Bash has an extensive set of variable expansion options. The one used here, '%', removes the smallest matching suffix from the value of the variable. The pattern is a glob pattern, so See the variable substition section of the bash manpage for more neat tricks. There's a lot that can be done within bash directly. | ||||
feedback
|
|
There shouldn't be spaces, newlines or other whitespace in the filenames, but this version of freiheit's answer handles those. It also uses
Even better - for the special case of just adding on to the end:
| ||||
|
feedback
|
|
| |||||||||||
feedback
|
Try it with an The problem with your original is that " | |||||||
feedback
|
|
The best tool is mmv.
Other examples of use (and of other tools) in "GNU/Linux Command-Line Tools Summary". | |||||||
feedback
|
|
The util-linux-ng package (on Fedora) has a
| |||
|
feedback
|
|
Yet another pure bash example using string replace.
Extra - this replaces all the occurrences of a string
| |||
|
feedback
|