in reply to Re: How to rename to lowercase every file in a directory and its subdirectories?
in thread How to rename to lowercase every file in a directory and its subdirectories?
rename "$_[0]","\L$_[0]";
This fails if the lowercase version of the directory already exists and is not empty.
Maybe worse is, it removes an existing but empty directory of the lowercase name.
So best to think about a warning:
unless ( -e "\L$_[0]" ) { rename "$_[0]","\L$_[0]"; } else { warn qq(been too afraid to move "$_[0]" to "\L$_[0]\E" - a file of + that name already exists.\n); }
Edit:
One further thought: the script might save some time skipping the renaming
if the original file or directory already is all-lowercase.
Cheers, Sören
|
|---|