Rename the extension of multiple files with shell script

Emmanuel Gautier / October 30, 2021

Shell script renaming recursively multiples files extension from the current directory. Here the change is for markdown, but you can change it easily to any other file extension.

Markdown

rename-multiple-fileextensions-markdown.sh
for x in **/*.md; do mv "$x" "${x%.md}.mdx"; done

Typescript

rename-multiple-fileextensions-typescript.sh
for x in **/*.js; do mv "$x" "${x%.md}.ts"; done