Making files and folders lowercase

Very occasionally I want to make all the files and folders of a particular directory lowercase (usually when porting an existing directory structure from Windows to Linux) this is how I do it. 

You could set up some form of recursive renaming script in a similar fashion to my post on ‘Batch Process in Bash‘. But it is much nicer to do it in just the one line, assume we want to change all the file and folder names inside the folder ‘/home/sean/windows/’:

find /home/sean/windows/ -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;

Job done!

This entry was posted in Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published.