Linux Rename File and Directory
To rename a file there are other commands also like 'mv'. But 'rename' command is slightly advanced then others. This command will be rarely used and it works differently on different distros of linux. We'll work on Debian/Ubuntu examples.
Generally, renaming is not a big task, but when you want to rename a large group of files at once then it will be difficult to rename it with 'mv' command. In these cases, it is adviced to use 'rename' command. It can convert upper case files to lower case files and vice versa and cn overwrite files using perl expressions. This command is a part of perl script.
This ('s/old-name/new-name/') is the PCRE (perl compatible regular expression) which denotes files to rename and how.
Let's see an example of basic rename command:
In the example below we have converted all the files ending with '.txt' into files ending with '.pdf'.
In another example, we have converted file into document for all files ending with .pdf
rename has some optional arguments but a mandatory perl expression that comes with every opption and guides it how to work.