In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use the ren command in cmd, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The use of ren is simple, and its format is: ren old file new file name. For example, rewrite test.txt to abc.txt and use ren test.txt abc.txt.
It is important to note that the old file can use either an absolute path or a relative path, but the new file name cannot use any path, only a new file name, even if the path is the current directory. For example, if you need to change the name of the file d:\ test\ abc.txt to xyz.txt, if the current path is located in d:\ test, the command can be written as: ren abc.txt xyz.txt, ren d:\ test\ abc.txt xyz.txt, but it must not be written as ren d:\ test\ abc.txt d:\ test\ abc.txt. The reason for this odd rule may be that once the path is written into a different directory, ren has the function of "move files + rename files", which is not consistent with its location.
Although the use of ren is simple, its function is very powerful, mainly due to ren support * and? These two wildcards: * represents any number of characters,? Represents a character. For example, to change all files with a .txt suffix to a .doc suffix, use ren *. Txt *. Doc, a simple statement, instantly changed a large number of files, CMD command concise and powerful features are reflected here incisively and vividly. For example, to rename a txt file that starts with an abc string and is only 5 characters to start with a xyz string, you can write: ren abc??.txt xyz??.txt.
What needs to be taken seriously is that when ren uses wildcards, its matching rules are very strange and too complex for beginners to understand, so I won't explain them in detail here. For more information, please refer to this post: is this a bug of ren? Http://www.cn-dos.net/forum/viewthread.php?tid=29538 . If you really need to use wildcards, it is recommended to read this post; if it is really difficult to understand, then choose the second choice, only use wildcards to modify the suffix, you do not have to delve into these complex rules.
Ren also has a very strange attribute: when the file has hidden properties or system attributes, ren will not work, you need to remove the hidden or system attributes of the file before renaming, for read-only files, ren can successfully rename. This creates a lot of trouble for us in many times: when you do not know whether the file to be renamed has hidden or system attributes, direct ren is very problematic; if you want to rename the file, you must also maintain the original file properties, which is even more painful.
What shall I do?
If you don't mind whether the properties of the file have been changed, the safe way is to use the attrib-s-h command to remove the possible system or hidden attributes of the file, and then ren it. If you are also required to rename the file to maintain the original attributes, the efficient approach is to first use the%% ~ ai expansion in the for statement to obtain the attributes of the original file, save them to variables after processing, and then use attrib-s-h to remove possible system attributes or hidden attributes of the file. After ren, read the attribute values retained in the variables and restore the original file attributes with attrib.
Ren also applies to folders.
The above is all the contents of the article "how to use ren commands in cmd". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.