Rename – A Command Line Tool For Renaming Multiple Files in Linux

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

59 Responses

  1. Still learning says:

    Works differently on CentOS7. Couldn’t use any perl -like expressions. Only options are -v, -s, -h, -V..

  2. Samim says:

    Hi Ravi,

    This is great post, but in my case I tries nothing happening, can you please help me on this, I’m trying below. Something is wrong ?

    rename -n ‘s/\.txt/\.html/’ *.txt

    • Ravi Saive says:


      Its due to wrong commas, used in the command, try to use the correct commas as shown in the following command.

      # rename -n 's/\.txt/\.html/' *.txt
  3. xnor says:

    if rename has some problems and different implementations (as suggested in some of the comments), then why is it any better than ‘sed’, which is decades older and very stable and well-documented?

  4. tilfer says:

    I got thousand of files with space in a folder. It is from Windows or something. I hate filename with spaces. What should I type in terminal to remove the space from the filename?

  5. Unop says:

    Be careful – the version of rename(1) on debian/ubuntu is based on Perl while the version on the red hat family isn’t – therefore the expressions aren’t portable.

    Also to upcase

    rename -n ‘$_ = uc’ *

    To downcase

    rename -n ‘$_ = lc’ *

  6. ramarasan.m says:

    Amazing tips. This is why Linux is Awesome.
    Thank you very much for your help :)

  7. Polar says:

    Backing up postfix mail files from mail server to WIN7 PC. The original mail files are named like this:,S

    Windows has an issue with the extention and files are copied with size 0, and recognizes them as .com executable. I discovered that it works fine when renaming the file to _com. I can even copy them over to a new mail server, and they are recognized by the new postfix server.

    My plan now is:

    cp /postfix/files/path/*,S /home/user/mail_backup/.

    next I tried this command, but nothing is happening, so I must be doing something wrong:

    rename -n ‘s/\.com:2,S$/\_com/’ *.com:2,S

    Please your advice.

    • Ravi Saive says:

      Give a try again with the help of following command with little modification.

      # rename -n 's/\.com/\_com/' *.com
  8. Prabhakar says:

    You just saved 4 hours of my time and made me to do the same job of 4 hours in just 2 minutes. :) Amazing tips. This is why Linux is Awesome.
    Thank you very much for your help :)

  9. WarboyIndia says:

    Great! I works in Ubuntu 14.04 LTS. Can you please explain the perl expressions also?
    I don’t get the pattern where and why to use “s/ $/” or “y/” etc. It’ll be helpful if you explain it a little.

  10. MD. Akter Hossain says:

    this command is not working on redhat linux………… why ?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.