Change the Extension of Multiple Files in Linux
Tagged with: command, files, Linux, multiple, rename
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]
Follow me(@binnyva) on Twitter
July 19th, 2009 01:21
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
July 19th, 2009 01:30
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
September 4th, 2010 16:12
hey. How would one do the same if the filenames had spaces in them?
December 24th, 2011 21:56
@Bradforf, Syntax for rename is wrong. Correct command is
find . -name “*.info” -exec rename s/.info/.txt/ {} \;