Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How can I recursively change the case of files and folders under bash

How can I convert all file names to lowercase in a directory and its subdirectories, using a command or batch script?

share|improve this question

marked as duplicate by Dennis Williamson, Jim B, womble, splattne Feb 16 '10 at 12:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

You mention "bash" and "cmd", which are two different environments. Which one is it? I'm assuming Bash? – Mark Henderson Feb 15 '10 at 0:59
By cmd I mean "command line" (terminal) – Kop Feb 15 '10 at 1:02
Ah. cmd usually refers to the Windows command-prompt. – Mark Henderson Feb 15 '10 at 1:36
Duplicate of:… – Dennis Williamson Feb 15 '10 at 1:41
up vote 2 down vote accepted

If you also want to rename the folder, use this script.

share|improve this answer

First off, tr can be used to translate text. tr [:upper:] [:lower:] will translate all upper case characters from stdin into lower case in stdout. So it's just a matter of working that into your script...

for $FILE in `find . -name [whatever] -print`
    do mv $FILE `echo $FILE | tr [:upper:] [:lower:]`

This is pretty ugly, and it spits out errors if the file name is already lower case. (because you try to move it onto itself) But it should do the job. Be sure to mod up whomever posts a cleaned up version.

share|improve this answer
This fails for files that have spaces in their names. – Dennis Williamson Feb 15 '10 at 1:38
This also fails for me if a subfolder contains capital letters. – Studer Feb 15 '10 at 1:42

This is mild variation to Christopher's answer,

find . -type f > files.txt
for f in $(cat files.txt);
    mv $f $(echo $f | tr [:upper:] [:lower:])

If you want to work on directories rather than files use,

find . -type d > dirs.txt
share|improve this answer