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

Consulting

If you're seeking solutions to a problem or need expert advice, I'm here to help! Don't hesitate to book a call with me for a consulting session. Let's discuss your situation and find the best solution together.

Share this post
Follow the RSS feed