Mass Capitalize Words in Filenames

Posted (Updated ) in Uncategorized

It’s a pretty common problem. You have a file titled firefly – 02 – the train job.mkv when it should be Firefly – 02 – The Train Job.mkv. It’s slow and arduous to rename manually especially if you have a lot of files so below is a single command to do it all for you!

rename "s/ ([a-z])/ \U\1\E/g" *.mkv

In the above example:

  • \U means uppercase
  • \1 means the first match (in our case that’s the first alpha after a space)
  • \E means end uppercase
  • *.mkv applies the rename command to all files ending in .mkv in the current folder.

Thanks to akf from stackoverflow for his helpful answer on this one.