On 7 Oct 2020 03:22 -0600, from arnold(a)skeeve.com:
Possibly
wrongly, I judge glob by things like how simple it is, to use
it doing "rename *.foo to *.bar" or "find filenames with spaces in
them, and rename to be - separated"
I often use a
find ... | sed 's/whatever/mv & other/' | sh -x
for fancy things like that. If I'm doing the same operation a lot,
I wrap it in a script.
I like rename from
https://metacpan.org/release/File-Rename for that
purpose. It takes a regular expressions (actually, Perl expression, so
could in principle be any valid Perl code) plus a set of file names,
and renames each file according to the regexp. Plus you don't need to
worry about things like quoting within the command as with the above,
and it even has -0 for when reading those extra-exotic file names from
stdin. (For one thing, I hope none of your files has a space or a
semicolon in its name with your style of rename as-is. :))
In Debian, that's
https://packages.debian.org/stable/rename; I suspect
other systems with reasonably large package repositories also offer it
prepackaged.
About the only downside is its dependence on Perl (after all, that's
rather heavyweight), but then again a lot of other things also depend
on Perl so it's kind of hard to have even a minimal modern system that
doesn't have Perl installed...
Having to escape every '.' would probably be even more annoying than
modern GNU ls's default non-"-N" behavior; and worse in the sense that
_most_ of the time, it would probably work without escaping it, but
when it doesn't work, it would break in various spectacular fashions.
--
Michael Kjörling •
https://michael.kjorling.se • michael(a)kjorling.se
“Remember when, on the Internet, nobody cared that you were a dog?”