Monday, October 6, 2008

How do you lower case filenames?

Today, I forced an issue with uper cased letters in filenames. I needed lower cased filenames. Yeah, i could write some awk, but I'm too lazy for that. There is actually a tool for that - the tr.

First of all, do a simple echo test:

for file in $(ls Uper-cased-filename.*); do echo $file | tr A-Z a-z; done

Is that what you wanted? Then go ahead:

for file in $(ls Uper-cased-filename.*); do mv $file $(echo $file | tr A-Z a-z); done


tr can even help you do more.
Check out tr man pages for more and some cool examples from tlpd pages.

No comments: