From ThomasAdam:
Rename all files in a directory to lower case
mmv "[A-Z]" "[a-z]" *
Or, for Debian users, assuming all files are in the same directory:
rename 'y/A-Z/a-z/' *
and assuming that they are in subdirectories under the current directory:
find -type f | xargs rename 'y/A-Z/a-z/'
(Note that the Debian version of “rename” is not the same as the version shipped with many other distributions. The above won’t work on Red Hat, for example. It is perl based.)
From ThomasAdam:
This example also is potentially dangerous, as it assumes *all* files in every subdirectory below the one you invoke it from is needed. To just change just those files in the current working directory:
find . -type -f -maxdepth 1 -exec rename 'y/A-Z/a-z/' {} ;
or to be consistent with Hugo’s original style:
find -type -f -maxdepth 1 | xargs rename 'y/A-Z/a-z/'
There is no difference between the two commands other than xargs can handle a slightly larger command-line chain.
Of course, what happens when a file contains a space? Or indeed, a directory? In instances such as this, you *could* do:
for i in *; do rename "$i" 's/some/expression/'; done
But this is cumbersome, since it invokes a new ‘rename’ process each time the loop is iterated. With find though, one can do:
find . type -f -maxdepth 1 -print0 | xargs -0 rename 'y/A-Z/a-z/'
The -print0 option to find, means treat the string, not delimiting on ” ” (the normal) but null-terminated strings (‘