Search code examples
macosshellterminalfile-renamebatch-rename

How can I batch rename files using the Terminal?


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


Solution

  • 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.