In the Linux system, simple commands can be used to rename files. Commonly used commands include mv command, rename command, mmv command, etc. Next, we will explain these methods in detail through this article.
1. mv command
The mv command can be used to move or rename files. If you want to rename a file, you can use the mv command and specify the original filename and the new filename. For example, if you want to rename the file oldboy.txt to oldboyed.txt, you can use the following command:
mv oldboy.txt oldboyedu.txt
2. rename command
The rename command can batch rename files. It uses regular expressions to match filenames and replaces the matched parts with new names. For example, if you want to rename all files ending in .txt to .html, you can use the following command:
rename 's/\.txt$/.html/' *.txt
This command replaces .txt with .html in all filenames ending in .txt.
3. mmv command
The mmv command can also be used to batch rename files. It uses wildcards to match filenames and replaces the matched part with the new name. For example, if you want to rename all filenames starting with old to filenames starting with new, you can use the following command:
mmv "old*" "new#1"
This command replaces old with new in all filenames beginning with old.
4. Use the GUI file manager
If you are using a Linux desktop environment, you can also use a GUI file manager to rename files. In most file managers, you can right-click on a file and select the "Rename" option. You can then type in a new filename and press Enter to complete the rename.