Search code examples
macosfilebash

How do I rename all files to lowercase?


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?


Solution

  • If you're comfortable with the terminal:

    1. Open Terminal.app, type cd and then drag and drop the Folder containing the files to be renamed into the window.
    2. To confirm you're in the correct directory, type ls and hit enter.
    3. Paste this code and hit enter:

      for f in *; do mv "$f" "$f.tmp"; mv "$f.tmp" "`echo $f | tr "[:upper:]" "[:lower:]"`"; done
      
    4. 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.)