Signup/Sign In

How To Use The rename Command On Linux

In Linux, the rename command is used to rename named files using the regular expression perlexpr. It has the ability to rename numerous files. This command will grab the file name from the standard input if the user does not give any filenames on the command line.

Syntax:

rename [options] expression replacement file...

rename -s: This option ignores symbolic links when renaming files.

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

rename -v: This option displays which files are being renamed, if any are being renamed.

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

rename -n: This option is used when the user just wants to view the final result.

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

rename -o: This option will not overwrite existing files.

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

rename -V: This command displays the version information before exiting.

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

rename -help: rename -help: rename -help: This option will display a help message before exiting.

rename -help

What's the Deal With mv?

mv is in perfect condition. The command works well and is available on all Linux distributions, as well as macOS and other Unix-like operating systems. As a result, it's always accessible. But there are occasions when a bulldozer, not a shovel, is required.

The mv command has just one goal in life: to relocate files. It has the pleasant side effect of being able to relocate an existing file into a new file with a different name. The end result is that the file gets renamed, and we get what we desire. However, mv isn't a specialized file renaming program.



About the author:
Pradeep has expertise in Linux, Go, Nginx, Apache, CyberSecurity, AppSec and various other technical areas. He has contributed to numerous publications and websites, providing his readers with insightful and informative content.