emgoto / emgoto-comments

This hosts the comments for my blog, emgoto.com.
https://emgoto.com
0 stars 0 forks source link

md-to-mdx-rename/ #17

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

How to rename all md files to mdx · Emma Goto

Recently I converted my Gatsby blog from Markdown to MDX, and I wanted to convert all my .md files over to .mdx for consistency’s sake…

https://www.emgoto.com/md-to-mdx-rename/?utterances=cd5eec3c191aa2d1ea339c0frwcSkLSNGGeQMHnUzkDyy0ohBO8gsHBHPVVvrIyR1zXgb1cVKWOnv%2FiJfFtY0zNPsFeMrCtHX%2FtbNSEZtZg%2B5oBj5JzeTUZQyEgnz5QRP7mx3QmLyhLTknXs%2Bp8%3D

strdr4605 commented 2 years ago

I had same issue, but I created a bash function:

recurseMDXtoMD() {
  for file in "$1"/*; do
    if [ -d "$file" ]; then
      recurseMDXtoMD "$file"
    else
      if [[ $file == *.mdx ]]; then
        mv "$file" "${file%.*}.md"
      fi
    fi
  done
}