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...

60 Responses

  1. Andy K says:

    Thanks – you saved me from going nuts!

  2. Charles Jie says:

    Thanks. I’ve written my own ‘rename‘ utility long ago and find this from your article now.

    Two to correct:

    1. In example “rename ‘s/\.html$/\.php/’ *.html“, the REPLACEMENT part is just a STRING or EXPRESSION(if /e specified), so the backslash for .php is redundant.

    2. “Second argument tells the rename command to substitute all the files with *.php." – a typo, should be "*.html".

  3. Dello says:

    You showed how to rename file extensions. How do rename multiple file names that are complete different? Like, if I have five files named: tentwo-23.png, goingeasy.png, fear.png, samson(7).png, and support.png. And I want to name them 1.png, 2.png, 3.png, etc.

  4. George says:

    I am switching from windows. I would like to know if there is a way to do something like windows does: Select all files in a folder, right click on one of them, select rename, type something like “aaa” and press enter.

    There could be 2 files or 2,000, but lets say there were 5. The result would be 5 files named as such:
    This would save a lot of time.

  5. Richard H Busby says:

    Very excellent help with the rename command thanks a lot I’ve been struggling with this for a while

  6. Mahmood Shehab says:

    Thanks for your post!

    Please add other section to capitalize only first letter of each filename.

    # rename 's/\b(\w)/\U$1/g' *.ext
  7. Andrea says:

    How to rename single wrong characters in multiple file in a folder and sub-folder with a string command ?

  8. S. Prashanth says:


    I am trying to rename multiple files in Centos7.

    For example: File I have:


    I want to rename them to:


    How can I achieve this?

    Thank you!

  9. Pedro Diaz says:

    I’m running Linux kernel version 106100LC004 2.6.32-573.el6.x86_64 #1 SMP Wed Jul 1 18:23:37 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux. And, my ‘rename‘ command expressions are like this:

    # rename .html .php *.html

    I then made an alias to shorten this command.

    # ren () { rename "$1" "$2" *"$1"; }

    So now my version is:

    # ren .html .php

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.