In Windows, we frequently come to achieve the same volume of work, a number of users typically search the net third-party software package. In reality, in Windows, clever use For command can quickly total the good deal of volume function. In order to superior comprehend our subsequent fight, permit us examine the For command use. For the certain format from the command is as follows:
For% variable IN (set) do command [command-parameters],
percent Variable - to specify just one letter replaceable parameter
(Set) - specify 1 or a group of files, it is possible to use wildcards
command - Specifies the command to execute on every file
command-parameters - specify the parameters to get a distinct command or command line switches
For use inside a batch file command, specify variables working with Variable names are case sensitive, so For the utilization from the commands and parameters is highly large, complicated changes, where one by one for reasons of room is no longer listed, the user can command prompt, type Now we'll go directly to actual combat, mixed with actual speak concerning the specific use For command.
one. Inscribed having a text file batch
In numerous instances, we have now completed editing the document, ought to include a file having a If only an write-up, let me say straight to the input, but when you have countless such files, tips on how to do it? Is every 1 a manuscript have to manually enter it word for phrase in stone inscription it? NO! This really is totally unnecessary trouble, we are able to add all of the files at once about the inscription to, if we give about the Then please construct a text file named Address.txt, mailing deal with entry, QQ, E-mail, and so on. info, saved to the root of E drive.
Include a new text file,
Microsoft Office Pro Plus, input the subsequent:
MD E: TEMPabcde
for / r E: ABCDE%% I in (*. txt) do copy%% I + E: tackle.txt E: tempABCDE
for / r E: tempABCDE%% I in (*. txt) do copy%% IE: ABCDE
echo y | del E: TEMPabcde
echo y | rd E: TEMPabcde
Entry is finished, the inspection confirmed correct, save as Now, just double-click the batch file, we can E: ABCDE folder inscribed with all of the TXT files.
Suggestion: For command to specify the parameters
two. Volume to get the listing of files
If we require to create a list of documents inside a directory, for instance the movie file checklist, you possibly can very easily utilize the For command to complete. We make all of the RM F disk film file formats a checklist of instance:
1st beneath the root directory F constructed a
For / r F: %% i in (*. rm) DO @ echo%% ~ fi>> F: RMList.txt
Double-click the batch file, you can speedily record all the disk F RM film file extension checklist.
Tip: For command to specify the parameters F? RMList.txt txt file, open the file, you may see a in depth directory listing; You are able to also use ),
3. Quickly remove empty folder around the disk
Suppose we desire to clean up area about the D drive folder, then use Notepad to construct a first identify
dir d: / ad / b / s | kind / r>> d: destroy.txt
For / f%% i in (d: kill.txt) DO rd%% i
echo y | del d: kill.txt
1st locate and delete all of the
Tip: Abstract: The parameter / r The cause for reverse sequence purchase, given that right after sorting by way of the reverse sequence, D generate for all sub-folders will usually be located in front of its father or mother folder,
Office Professional Plus 2007 Key, so that in use For command to delete an empty folder, empty sub-folders was initial removed, so the empty father or mother folders to be deleted. Otherwise, because of the father or mother folder of an empty sub-folders are still empty, will cause the scenario can not be deleted.
For the command parameters passed towards the command line RD; RD command would be to delete the command is passed over through the For each and every folder, RD command can't be deleted due to the fact the contents from the folder there, it cycles via the For command, just delete all of the empty file folder,
Office Pro Plus, the contents of the folder will have been preserved intact.
4. Volume to get the LAN IP address and host name of all correspondence between
Should you be a Webmaster, definitely need to have to obtain an IP tackle of the subnet and host title of all the control table. If you don't would like to use third-party computer software, then, may well desire to make use of For command to try.
At the command prompt sort the adhering to command:
For / L% i in (0,1,254) DO ping-a-n one 192.168 .. 0.percent I | Locate / i
Okay, so the command is finished, open the
Suggestion: For command to specify the parameters If your user-defined from the LAN IP deal with should be set according to the actual scenario, including for default is four occasions; Obtain / i