How do I rename all files to lowercase?

bash, file, macos

Solution

If you're comfortable with the terminal:

- Open Terminal.app, type `cd` and then drag and drop the Folder containing the files to be renamed into the window.

- To confirm you're in the correct directory, type `ls` and hit enter.

Paste this code and hit enter:

for f in *; do mv "$f" "$f.tmp"; mv "$f.tmp" "`echo $f | tr "[:upper:]" "[:lower:]"`"; done

- To confirm that all your files are lowercased, type `ls` and hit enter again.

(Thanks to @bavarious on twitter for a few fixes, and thanks to John Whitley below for making this safer on case-insensitive filesystems.)

Problem

I have for example TREE.wav, ONE.WAV. I want to rename it to tree.wav, one.wav. How do I rename all files to lowercase?

Original source