Q:

File extension case sensitivity on CentOS

Possible Duplicate:
How to clean up file extensions? 

I'm using CentOS. There are >10M images in one of my folders, which are furthur grouped into subdirectories.
The issue is that some of my images are named as abc.jpg and others are named as xyz.JPG. So, when i try to access xyz.jpg, it says "File not found" as the extension is case-sensitive.
Is there any way to rename all JPG to jpg, or a httpd config which works around this issue.

A:

Try this (this will rename all .JPG files to .jpg recursively, in all the subdirectories of the directory where you run this):
find . -name '*.JPG' -exec sh -c 'mv "$0" "${0%.JPG}.jpg"' {} \;

The find searches for all files named *.JPG in the current directory and its subdirectories, passes the list to the mv command which renames them

A:

As always with this kind of questions and answers, a few words of caution:
find . -name '*.JPG' -exec sh -c 'mv "$0" "${0%.JPG}.jpg"' {} \;

While it will work OK for most people in most cases, it's dangerous to advertise it publicly as it got a few issues that may turn to security issues in some contexts.
That renames both files and directories. If renaming directories, it will fail to rename files within (use the -depth option)
It will potentially lose files (foo.JPG renamed to foo.jpg while there already was a foo.jpg), or potentially put files where you don't want to (consider for instance a directory where there's a file called foo.JPG and one called foo.jpg that is actually a symlink to /etc/apache2/conf.d. It will potentially break symlinks. There's a race condition that can allow an attacker trick you into renaming any file.
Many of those issues can be avoided by using a tool dedicated for that task (batch renaming of files) instead of trying to reinvent the  wheel. mmv and zsh's zmv come to mind.

