3 ms·
Don't read it like this: rename <expression> <replacement file> ... Read it like this: rename <expression> <replacement> <file(s)...> Argument 1 is a string
by loudmax 9y ago
Don't read it like this:
rename <expression> <replacement file> ...
Read it like this:
rename <expression> <replacement> <file(s)...>
Argument 1 is a string (not a regex), argument 2 is string to replace the old string, and arguments 3+ is a file, or list of files, or a glob.
The man page includes a warning about the lack of safeguards. It is unfortunate that rename doesn't have an equivalent of mv or cp's -i flag because it's so easy to overwrite files if your expressions aren't exactly correct.
On some Ubuntu systems, I've seen another version of rename that's actually a Perl script that uses regular expressions. I think that version lets you set some safeguards, which are sorely lacking in the binary version of rename that ships with CentOS.