May 25, 2009

Rename files easily

Posted in Tips tagged , at 2:09 pm by Karel MALBROUKOU

A lot of people asked me how to rename files easily and fast enough. We all know the command mv which is used to move files but we can use it to rename files as well (which will be the same operation as moving a file into the same directory).
But we do have a command that has the purpose to actually rename a file: rename.

How to use that command. I’ll show with an example.
For example, you want to move all your files that finishes by ‘.JPG’ to ‘.jpg’.

Here’s the command line:
find / -name "*.JPG" -exec rename JPG jpg {} \;

And hop! Another way to make your life on Linux easier and faster!

3 Comments »

  1. alti said,

    you don’t need the find 🙂

    rename ‘s/\.JPG/\.jpg/’ *.JPG

    • Good point, but find is here to make the use of rename recursively 😛

      I knew the use of the command as rename ’s/\.JPG/\.jpg/’ *.JPG, but not working on my system…
      weird thing :@

  2. Great site, I will be back. Well done


Leave a reply to alti Cancel reply