PDA

View Full Version : Change suffix


Matsaki
August 26th, 2008, 09:13 PM
How do I change the suffix .JPG to .jpg in the terminal / UNIX ?

macbri
August 26th, 2008, 09:46 PM
For one file or many?

One file:
mv somefile.JPG somefile.jpg

Many files in one place (using bash):
for file in *.JPG; do mv $file ${file%.*}.jpg; done

Many files in many directories below the current directory (using bash):
for file in $(find . -name \*.JPG -print); do mv $file ${file%.*}.jpg; done

Since "mv" doesn't care to ask your permission, it'll happily overwrite files if it needs to. So use with caution.

Matsaki
August 27th, 2008, 06:14 AM
Many thanks! It was 12.000 files and made my life easier :)