Changing file names in a directory

Here I am changing a whole directory of file names. I am changing the extension of any file with the .tif extension to .jpg.

ls *.jpg | awk ‘{print(”mv “$1″ “$1)}’ | sed ’s/.jpg/.tif/2′ | /bin/sh

Of course you can change the sed regular expression to change it to whatever you want to change the file names to, and change the ls command to grab the filenames you want to change.

One Response to “Changing file names in a directory”

  1. Andy Says:

    for i in *.jpg; do mv $i ${i%%.jpg}.tif; done