In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about the Linux system how to rename multiple files at a time. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Syntax: rename [- v-n-f]
Is a Perl-compatible regular expression that represents the file to be renamed and what to do. The regular expression is in the form of'sAccordLay _ name_ _ new _
The'- v 'option shows the details of the file name change (for example, rename XXX to YYY).
The'- n 'option tells the rename command to show that the file will be renamed without actually changing the name. This option is useful if you want to simulate a file name change without changing the file name.
The'- f 'option forces existing files to be overwritten.
Case demonstration: change the file extension
Suppose you have a lot of .jpeg picture files. You want to change their names to .jpg. The following command changes the .jpeg file to * .jpg.
/ .jpg /'* .jpeg
Change uppercase to lowercase, and vice versa
Sometimes if you want to change the case of the file name, you can use the following command.
Change all files to lowercase:
# rename'yUnix Amurazapa Muhamzono'*
Change all documents to uppercase:
# rename'yUniqa MuyzCompa Amurz Universe'*
Change the file name schema
Now let's consider more complex regular expressions that contain subpatterns. In PCRE, the subpattern is contained in parentheses, followed by a number (for example, 1 ~ 2).
For example, the following command turns' imgNNNN.jpeg' into 'danNNNN.jpg'.
# rename-v 's/img (\ d {4}) .jpeg$/dan$1.jpg/' * .jpeg
Img_5417.jpeg renamed as dan_5417.jpg
Img_5418.jpeg renamed as dan_5418.jpg
Img_5419.jpeg renamed as dan_5419.jpg
Img_5420.jpeg renamed as dan_5420.jpg
Img_5421.jpeg renamed as dan_5421.jpg
For example, the following command turns' img_000NNNN.jpeg' into 'dan_NNNN.jpg'.
# rename-v 's/img\ d {3} (\ d {4}). Jpeg$/dan$1.jpg/' * jpeg
Img_0005417.jpeg renamed as dan_5417.jpg
Img_0005418.jpeg renamed as dan_5418.jpg
Img_0005419.jpeg renamed as dan_5419.jpg
Img_0005420.jpeg renamed as dan_5420.jpg
Img_0005421.jpeg renamed as dan_5421.jpg
In the above example, the subpattern'\ d {4} 'captures four consecutive digits, and the four digits captured are $1, which will be used for the new file name.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
This is how the Linux system shared by the editor renames multiple files at a time. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, 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.