“Flatten” file names in the terminal

I am often dealing with folders with lots of files with weird file names. Spaces, capital letters, and so on, often cause problems. Instead of manually fixing such file names, here is a quick one-liner (found here) that can be run in the terminal (at least on Ubuntu) to solve the problem:

rename 'tr/ A-Z/-a-z/' -- *

It is based on a simple regular expression, replacing any spaces with hyphens, and changing any capital letters to lower case.

Published by

alexarje

Alexander Refsum Jensenius is a music researcher and research musician living in Oslo, Norway.