Rename several file extensions in the command line

Published on

This script iterates over a list of files with a specified file extension (in this case they are Matroska files) and renames them.

Type the script below directly into the command line, hitting “return” after each line.

$ for file in *.mkv
$ do mv "$file" "${file/.mkv/.avi}"
$ done