How can I batch rename files using the Terminal?

Jake Wilde picture Jake Wilde · Mar 22, 2011 · Viewed 78.3k times · Source

I have a set of files, all of them nnn.MP4.mov. How could I rename them so that it is just nnn.mov?

Answer

kurumi picture kurumi · Mar 22, 2011

First, do a dry run (will not actually rename any files) with the following:

for file in *.mov
do
  echo mv "$file" "${file/MP4./}"
done

If it all looks fine, remove the echo from the third line to actually rename the files.