On 2026-02-20 01:00, Russell L. Harris wrote:
Check out the Perl rename utility (written by Larry Wall) which has
been renamed "file-rename".
Everyone ought have a copy of the wonderful O'Reilly book "Learning
Perl".
If you want to start writing your own utilities, any decent language
will do. Some have better support libraries than others. The recommended
"Camel book" is excellent though.
But the core problem here was not understanding shell expansion, and a
lack of confirmation.
Understand that unlike on DOS, Unix programs do not need to interpret
wildcards like *. The shell does that. So when you type
mv *.txt foo, your shell expands *.txt and mv only sees the result.
ren *.txt *.cnn would be tricky. *.txt would expand to all of your .txt
files in the current directory. *.cnn would be passed into your ren
program only if you have no .cnn files in the current directory.
Otherwise you would have to escape shell expansion by typing \*.cnn,
which is not very friendly to use.
I much prefer the unix approach, but I'm used to it.
If you start writing your own utilities, use version control for your
entire home shell setup. I can't recommend that more. I use Git for
everything, so now setting up a new login on a new box, or syncing up my
config on each box, is a simple git pull followed by a make install.
Cheers,
Mike