Changing file extensions in the terminal

Posted by Steven Clontz on February 21, 2014

So I can’t exactly publish this while I’m in the middle of moving my site to nanoc, but here’s another bash one-liner for mass-changing an old extension *.old to a new one *.new within a folder.

for file in *.old; do mv "$file" "${file%.*}.new"; done

Pretty useful: I wanted to change from Octopress’s *.markdown extension to the more typical *.md for my blog posts, and that saved me a few clicks!