For your particular question this command will work. Verify that you are happy with the proposed renaming, then drop the -n
to have the operation proceed.
rename -n 's/\.xvg$/.txt/' *.xvg
This basically means for all files with the .xvg
extension in the current directory find the files that end ($
) with .xvg
and change that part of the name to .txt
.
More detail and an example below.
Yes, the rename
command will do this for you. A short example where I rename all of my files with the .html
extension to .html_bak
, ignoring other files in the directory.
I would strongly recommend using the -n
command line option first (explained below) to see what changes would happen before executing the actual command.
What I start out with:
$ ls
a.html a.txt b.html htmlfile
the -n
means do a "trial run" .. just show what would change, don't change anything!
$ rename -n 's/\.html$/.html_bak/' *
a.html renamed as a.html_bak
b.html renamed as b.html_bak
Still have the original files.
$ ls
a.html a.txt b.html htmlfile
Now for real:
$ rename 's/\.html$/.html_bak/' *
Files have been renamed.
$ ls
a.html_bak a.txt b.html_bak htmlfile
In the above examples I use *
to specify the files to be considered for the rename operation. I could have restricted this to .html
files only with *.html
.
For more information consult the rename man page