3 thoughts on “Linux how to change the file extensions for multiple files in a directory

  1. That works great if your file names don’t have any spaces in them. However if they do try this:

    for f in *.OLD; do mv “$f” “`basename “$f” .OLD`.new”; done;

    I most often use this for photos, a lot of cameras use an uppercase JPG as a file extension and some programs get confused (Thunderbird, I’m looking at you!) by uppercase file extensions.

    I use it so often I even have an alias in my .bashrc.

    alias JPG=’for f in *.JPG; do mv “$f” “`basename “$f” .JPG`.jpg”; done;’

Comments are closed.