In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you what the Linux system renames multiple files at a time is the specific solution, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.
If you simply rename a file, you will only need to use the mv command, but how to rename more than one file at a time?
Rename multiple files at a time in Linux
The mmv program can be used in the default repository of Debian-based systems. To install it on Debian, Ubuntu, Linux Mint, run the following command:
$sudo apt-get install mmv We assume that you have the following files in the current directory.
Ls a1.txt a2.txt a3.txt now, you want to rename all files that start with the letter "a" to start with "b". Of course, you can do this manually in a few seconds. But think about whether you have hundreds of files you want to rename? This is a very time-consuming process. The mmv command is very helpful at this point.
To rename all files that begin with the letter "a" to those that begin with the letter "b", simply run:
$mmv a\ * b\ # 1 Let's check to see if the files have been renamed.
Ls b1.txt b2.txt b3.txt as you can see, all files that start with the letter "a" (that is, a1.txt, a2.txt, a3.txt) are renamed to b1.txt, b2.txt, b3.txt.
explain
In the above example, the first parameter (a\ *) is "from" mode, and the second parameter is "to" mode (b\ # 1). Based on the above example, mmv will look for any file name that starts with the letter "a" and rename the matching file, the "to" pattern, based on the second parameter. We can use wildcards, such as *,? And [] to match one or more arbitrary characters. Please note that you must escape using wildcards, or they will be extended by shell and will not be understood by mmv.
# 1 in "to" mode is a wildcard index. It matches the first wildcard in the "from" pattern. # 2 in "to" mode will match the second wildcard, if any, and so on. In our example, we only have one wildcard character (asterisk), so we write a # 1. And the # symbol should also be escaped. In addition, you can enclose the pattern in quotation marks.
You can even rename all files with a specific extension to another extension. For example, to rename all .txt files in the current directory to .doc file format, simply run:
$mmv\ * .txt\ # 1.doc this is another example. Let's assume that you have the following documents.
Ls abcd1.txt abcd2.txt abcd3.txt you want to replace the first occurrence of "abc" with "xyz" in all files in the current directory. What would you do?
It's simple.
Note that in the above example, the pattern is enclosed in single quotation marks. $mmv'* abc*''# 1xyzroom2'
Let's check to see if "abc" is actually replaced with "xyz".
$ls xyzd1.txt xyzd2.txt xyzd3.txt. See? The files abcd1.txt, abcd2.txt, and abcd3.txt have been renamed xyzd1.txt, xyzd2.txt, and xyzd3.txt.
Another noteworthy feature of the mmv command is that you can print the output using the-n option instead of renaming the file, as shown below.
$mmv-n a\ * b\ # 1 a1.txt-> b1.txt a2.txt-> b2.txt a3.txt-> b3.txt so that you can simply verify what the mmv command actually does before renaming the file.
See the man page for more details.
Man mmv update: Thunar File Manager Thunar File Manager has a built-in bulk rename option by default. If you are using Thunar, renaming files is much easier than using the mmv command.
Thunar is available in the default repository for most Linux distributions.
To install it on an Arch-based system, run:
$sudo pacman-S thunar on RHEL and CentOS:
$sudo yum install thunar on Fedora:
$sudo dnf install thunar on openSUSE:
$sudo zypper install thunar on Debian, Ubuntu, Linux Mint:
After sudo apt-get install thunar is installed, you can start the batch rename program from the menu or from the application launcher. To start it from the terminal, use the following command:
The batch renaming of $thunar-B is as follows.
Click +, and then select the list of files to rename. Batch renaming can rename the file name, the file suffix, or rename the file name and suffix at the same time. Thunar currently supports the following batch renaming:
Insert date or time
To insert or cover.
Serial number
Delete character
Search and replace
Upper or lowercase
When you select one of the conditions from the list of options, you will see a preview of the changes in the New name column, as shown in the screenshot below.
After selecting the condition, click the rename File option to rename the file.
You can also open the batch rename from Thunar by selecting two or more files. After selecting the file, press F2 or right-click and choose rename.
What are the versions of Linux? the versions of Linux are Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and so on. Among them, Deepin is one of the best-developed Linux distributions in China; UbuntuKylin is a derivative release based on Ubuntu; Manjaro is a Linux release based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP's easy-to-use; Ubuntu is the Linux operating system based on desktop applications.
The above is what is the specific solution for Linux system to rename multiple files at a time. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.