Linux: Rename all files extension from upper to lower cases

Friday, 14th February 2014

Reading Time: < 1minute

Lets say you're an admin involved in webhosting and due to a programmer's mistake, you end up with directory full with files with extension in upper cases but for actual version of website (all pictures are red only in lower cases), hence would like to transform these to lower cases.
To give an example, to illustrate what I mean, lets say you have in a directory files like;

filename.JPG, picture.PNG, new-picture.GIF

and you would like all files to be renamed to lower extension characters, i.e.:

filename.jpg, picture.png, new-picture.gif.
 

# find . -name '*.*' -exec sh -c 'a=$(echo {} | sed -r "s/([^.]*)$/L1/"); [ "$a" != "{}" ] && mv "{}" "$a" ' ;

That's all enjoy 🙂

Share this on:

Download PDFDownload PDF

Tags: , , , , , , , , , , , ,

Leave a Reply

CommentLuv badge