rename command in Linux with Examples

rename command in Linux is used to rename the named files according to the regular expression perlexpr. It can change the name of the multiple files. If the user will not specify any file names on the command line with this command then it will take the file name from the standard input.

Syntax:

rename [options] expression replacement file...

Options:



  • rename -s: This option renames the files ignoring the symbolic links.

    Example:

    rename -s 's/root/new/' sym.png

  • rename -v: This option is used to show which files is being renamed, if there is any.

    Example:

    rename -v 's/jpeg/png/' *.jpeg

  • rename -n : This option comes into play when the user wants to see only the final change.

    Example:

    rename -n 's/png/jpeg/' *.png

  • rename -o : This option will not going to overwrite the existing files.

    Example:

    rename -o 's/jpeg/png/' *.jpeg

  • rename -V: This option will show the version information and exit.

    Example:

    rename -V 's/jpeg/png/' *.jpeg

  • rename -help : This option will going show the help message and exit.

    Example:

    rename -help



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.