So on today’s task list at work I am going through 1,000+ files and renaming them to no longer be camel case. After about 2 minutes of this I decide, what a waste of time to do manually! So I did some searching on the tubes and found this article on Linux Journal.
It shows this very simple shell script! All you have to do is throw this in text wrangler/editor, save as a .sh then cd to the directory where your files are and run the script. It will ask you if you want to overwrite each file, which at first I was a little annoyed by but in reality it’s good to get a visual check on each file to make sure it’s doing what you want before overwriting.
There are some other ways to do this process in the comments of the article, and you should take note Phil wrote this quite a few years ago and it doesn’t take into consideration files with spaces, but for my purposes it worked great!!!
#!/bin/sh # lowerit # convert all file names in the current directory to lower case # only operates on plain files--does not change the name of directories # will ask for verification before overwriting an existing file for x in `ls` do if [ ! -f $x ]; then continue fi lc=`echo $x | tr '[A-Z]' '[a-z]'` if [ $lc != $x ]; then mv -i $x $lc fi done