The magic of the For command in Windows

  

In Windows, we often have to do the same work in batches. Many users often search for third-party software online. In fact, in Windows, clever use of the For command can easily do a lot of batch work. In order to better understand our next step, let us look at the usage of the For command. The specific format of the For command is as follows: For %variable IN (set) do command [command-parameters], %variable——Specify a single-letter replaceable parameter (set)——specify one or a set of files, Use the wildcard command—— to specify the command to execute on each file command-parameters——specify parameters or command line switches for specific commands. When using the For command in a batch file, use “%%variable” And don't use “ %variable”. Variable names are case sensitive, so “%i” is different from “%I”. Due to the many usages and parameters of the For command, the changes are complicated. Because of the space, the list is no longer listed. Users can type “& /quo; For /?” at the command prompt to get specific help. Below we will go directly to the actual combat, and combine the actual combat to tell the specific usage of the For command. 1. Adding texts to text files in batches In many cases, when we edit and process the documents, we must add a message including “Address, QQ, E-MAIL, etc.” to the file, such as the registration to the editorial department. Manuscript. If there is only one article, it can be directly input, but what if you have a lot of such documents? Is it necessary to enter the same amount of text in a single word by hand? NO! There is absolutely no need to be so frustrated, we can add and drop all documents at once, if we want to add all the text files placed in the “ABCDE” directory. Then please build a text file named Address.txt, enter the communication address, QQ, E-mail and other information, and save it to the root directory of the E drive. Create a new text file and enter the following: MD E:\\TEMPabcde for /r E:\\ABCDE %%I in (*.txt) do copy %%IE:\\address.txt E:\\tempABCDE\\ for /r E :\\tempABCDE %%I in (*.txt) do copy %%IE:\\ABCDE\\ echo y

Copyright © Windows knowledge All Rights Reserved