Search code examples
macosterminalfile-extension

Changing file extensions for all files in a directory on OS X


I have a directory full of files with one extension (.txt in this case) that I want to automatically convert to another extension (.md).

Is there an easy terminal one-liner I can use to convert all of the files in this directory to a different file extension?

Or do I need to write a script with a regular expression?


Solution

  • You could use something like this:

    for old in *.txt; do mv $old `basename $old .txt`.md; done
    

    Make a copy first!