Q:

Batch renaming of files

I have a directory full of images:
DSCN4749.JPG
DSCN4750.JPG
DSCN4892.JPG
...

And I would like a one-liner to rename them to (say).
dscn4749.jpg
dscn4750.jpg
dscn4892.jpg
...

How do I do this?
Alternatives/extenstions/caveats

I want to recurse
The directory contains a mix of file types I only want to rename DSCN*.JPG files.
bash solution
perl solution
zsh solution
I want a new directory tree with hard links existing files.
I want to change name more than just a case change eg dscn5555.JPG to 05555.jpg

...

A:

With perl rename
rename 'y/A-Z/a-z/' *

A:

POSIX sh for loop
for i in ./DSCN*JPG; do mv "$i" "$(echo "$i" | tr A-Z a-z)" ; done

bash while loop
good for unlimited number of files, reading a list of names from a file
Reading names from find command.
find . -maxdepth 1 -type f -name 'DSCN*JPG' | while IFS= read -r f; do
  mv -v "$f" "$( tr A-Z a-z <<< $f )"
done

Reading list of names in a file named flist
while IFS= read -r f; do mv -v "$f" "$( tr A-Z a-z <<<$f )"; done < flist

A:

Some linux distributions have a program called "mmv" (e.g. debian).  This can perform a rename based on pattern matching of filenames.  In your case, the command you'd want is:
mmv 'DSCN*.JPG' 'dscn#1.jpg'

It interprets the filename pattern itself, rather than relying on shell expansion, so remember to quote the wildcards.  In the destination pattern, #1 refers to the first wildcard in the source pattern and so on.  I'd suggest running
mmv -n 'DSCN*.JPG' 'dscn#1.jpg'

first, which will give a list of operations that will be performed as a dry run.
It can also handle recursively renaming, using the special ; pattern (which matches any number of subdirectory levels, similarly to the ** pattern used by some other tools).  So to perform this operation recursively, the command is:
mmv ';DSCN*.jpg' '#1dscn#2.jpg'

It can also handle case transformation of the filenames itself, so if you weren't sure that all your files started with the DSCN prefix, for example, the following would work:
mmv '*.JPG' '#l1.jpg'

or even
mmv '*' '#l1'

or
mmv ';*' '#1#l2'

to perform the rename recursively.
A new directory tree with hard links to the original files can be produced using the -l option:
mmv -l ';DSCN*.JPG' '../output/#1dscn#2.jpg'

I haven't tested this, but I believe it will create directories as necessary.

