I have three files named
file1.txt
file2.txt
file3.txt
I am trying to rename them to
mynewfile-1.txt
mynewfile-2.txt
mynewfile-3.txt
How would I go about this using regular expressions?
I have three files named
file1.txt
file2.txt
file3.txt
I am trying to rename them to
mynewfile-1.txt
mynewfile-2.txt
mynewfile-3.txt
How would I go about this using regular expressions?
Try this :
or from comments :
(remove -n switch when your tests are OK)
There are other tools with the same name which may or may not be able to do this, so be careful.
If you run the following command (
GNU
)and you have a result like
and not containing:
then this seems to be the right tool =)
If not, to make it the default (usually already the case) on
Debian
and derivative likeUbuntu
:(replace
/path/to/rename
to the path of yourperl's rename
command.If you don't have this command, search your package manager to install it or do it manually (no deps)
Last but not least, this tool was originally written by Larry Wall, the Perl's dad.