I was looking for a linux command line one-liner to rename a bunch of files in one shot.
pattern1.a pattern1.b pattern1.c ...
Once the command is executed I should get
pattern2.a pattern2.b pattern2.c ...
I was looking for a linux command line one-liner to rename a bunch of files in one shot.
pattern1.a pattern1.b pattern1.c ...
Once the command is executed I should get
pattern2.a pattern2.b pattern2.c ...
If you happen to be using Linux, you may also have a perl script at /usr/bin/rename which cane rename files based on more complex patterns than shell globbing permits.
The /usr/bin/rename on one of my systems is documented here. It could be used like this:
A number of other Linux environments seem to have a different
rename
that might be used like this:Check
man rename
on your system for details.Before you run it, stick an
echo
in front of themv
to see what it would do.Plenty of ways to skin this cat. If you'd prefer your pattern to be a regex rather than a fileglob, and you'd like to do the change recursively you could use something like this:
As Kerrek suggested with his answer, this one first shows you what it would do. Pipe the output through a shell (i.e. add
| sh
to the end) once you're comfortable with the commands.This works for me: