Change all the .txt files to .md files in a certain folder

file conversionterminal

Is there a Terminal command or something like that to batch rename files in a certain folder? Basically I want to change all the files that have a .txt as a file type, and change it to .md (for markdown). Is this possible? I am comfortable using the Terminal, being a developer, so don't hold back on solutions. 🙂

Thanks in advance for any help you can provide.

Best Answer

You can do the following in Terminal:

find . -iname "*.txt" -exec bash -c 'mv "$0" "${0%\.txt}.md"' {} \;

This will recursively rename all .txt files in the current directory to .md.