[kwlug-disc] bash - file renaming
Ronald Barnes
ron at ronaldbarnes.ca
Fri Sep 27 02:35:02 EDT 2019
Jason Eckert wrote on 26/09/2019 04.04:
> Why not write a simple for loop in bash?
> for $FILE in *
> do
> mv $FILE $FILE.whatever
> done
Hi Jason,
I'm looking for the syntax style of the DOS ren utility which I still
have in muscle memory all these years later.
And which matches, roughly, the syntax of "cp" and "mv".
I like to think of what I wrote as "one loop to rule them all".
Also, writing / editing a script each time a task requires it is not
particularly efficient. I find it preferable to write it once and reuse
indefinitely.
This script handles many different scenarios without modifications.
Writing a script each time the need pops up is inefficient and leads to
errors creeping in (quotes...).
Finally, it was an excellent deep dive into bash - using many of the
different substitutions it provides. That alone made it all worthwhile.
Cheers,
rb
More information about the kwlug-disc
mailing list