In this example, we will change all files with extension ‘.info’ to ‘.txt’.
Rename all *.info files in one folder
rename .info .txt *.info
That should read as..
rename <replace this string> <with this string> <in all these files>
Do the same operation recursively in a directory tree
find . -name "*.info" -exec rename .info .txt {} \;
Those double quotes around *.info are important – don’t remove them mm-kay?
[tags]rename,multiple,command,linux,files[/tags]
Not working for me, I’m getting the error
syntax error at (eval 1) line 1, near “.”
when I type in
rename .mp4 .mpg *.mp4
I found the following website helpful: http://www.thegeekstuff.com/2009/06/how-to-rename-files-in-group/
So the rename command could be
rename s/.ext1/.ext2/ *.ext2
hey. How would one do the same if the filenames had spaces in them?
@Bradforf, Syntax for rename is wrong. Correct command is
find . -name “*.info” -exec rename s/.info/.txt/ {} \;
Stephen, thanks – that worked.
Worked like a charm with CentOS 6’s standard tools and standard shell (bash)
@Bradford, you’re not super likely to read this 4.5 years later, but try
rename ‘.mp4’ ‘.mpg’ *.mpg
for your situation =0