Rename the extension of multiple files with bash script on Mac and Linux
Sometimes we need to rename the extension of multiple files extension in the current directory. Here some shell script snippets to do that in different cases.
Markdown to MDX
If you want to move from markdown
with .md
extension to .mdx
:
rename-multiple-files-extensions-markdown.sh
for x in **/*.md; do mv "$x" "${x%.md}.mdx"; done
Javascript to Typescript
If you want to move from a Javascript project with .js
files extension to Typescript files with .ts
extension:
rename-multiple-files-extensions-typescript.sh
for x in **/*.js; do mv "$x" "${x%.md}.ts"; done