I’m trying to write a shell script to go through and automatically rename all my mp3’s to a standard naming scheme, one of the key points being that I want the first letter of each word capitalized. This is where I’m running into my first major crash.
I tried doing
for i in *.mp3; do echo $i|sed 's/^[a-z]/[A-Z]/';done
as a test to see if I could capitalize the first letter of the name of each file, but then as you all know, I ended up with “[A-Z]ameo - word up.mp3” as a sample filename. So I tried doing all sorts of things, none of which worked. sed y/// and tr, on the other hand, happily uppercase all the letters, but that’s just as annoying as all lowercase.
So I’m still experimenting, but any advice would be hugely appreciated.
Well, I finally got it, and I did it all using sed, including a piece I grabbed from the USENET archive on google.
In case there’s anybody who’s as weak at shell scripting as I am, I’m posting my script here, fully commented. The part that does the actual work only takes up about 350 bytes, but I thought maybe somebody could learn from my trouble, so I spent 10 minutes explaining what I did (for all you guys who kick my ass at scripting, you aren’t the ones I wrote the comments for! ;))
Thanks much to all who posted help. Any further comment or criticism is welcome.
Detailed comments are the key to altering the script to meet changing needs. Great script. Undoubtedly you will end up wanting to change it in few months. Without those comments, you would end up started from scratch. Great job.