Batch Renaming in Linux Environment(批量重命名linux)
Linux environment is a versatile system, and a powerful batch renaming feature is one of its numerous useful components. This feature streamlines changing the name of multiple files or folders at once. It works properly in both the Graphical User Interface (GUI) and the Command Line Interface (CLI) environments.
Batch renaming in Linux system is currently available in many popular file managers such as Nautilus, Dolphin, Caja, Thunar, Pantheon Files, and Konqueror. It is also supported in the command line environment via the mv and rename commands.
In a GUI environment, batch renaming is achieved by selecting the files or folders and right-clicking them. From the menu options that appear, select “Rename” and then type in the new desired name. The files or folders will then be renamed with the string that was entered.
For example, if the original file name is “image.png”, and the new name that is desired is “photo1.png”, one would just type in “photo1” in the rename field and then click “Rename”.
In the command line environment, one can use the mv or rename commands to perform batch renaming operations. For example, to rename all the files in the current working directory from “image.png” to “photo1.png”, the following command can be used:
$mv image.png photo1.png
Or, to rename all the files in the current working directory that start with “image” to “photo”, the following command can be used:
$rename 's/image/photo/' *.png
For more complex tasks, one can make use of the Perl-based rename command. This command allows one to perform regular expression based tasks, such as the ability to rename all the files in the current working directory that contain the “image” string at the beginning to “photo”. The following command can be used for this purpose:
$rename 's/^image/photo/' *.png
Batch renaming is a powerful but often underused feature of the Linux environment. It is easy to use and makes work with files and folders much faster, as one can quickly and easily rename multiple files/folders with a single command.