It is often useful to be able to rename multiple files at the same time. Typical cases include changing a file extension (eg. .jpeg to .jpg) or renaming a set of files moved from one server to another (such as when repairing database replication, eg. slave1-bin. to slave2-bin.)
It is possible to write a shell script that will perform this task, but the ones I have seen are cumbersome and not very intuitive.
There is a script, I believe it comes bundles with Perl installation (at least on Debian), that allows files to be renames using regular expressions. It is simple to use, but lets you harness the power of perl regular expressions.
The basic syntax that I use most often involves using a substitute command (similar to those used in sed for example)
eg: Rename all jpeg images to jpg files in the images directory.
1
|
|
Mmm… Regex…