In the for command statement parameter F, the most difficult to understand is the delims and tokens options. This article makes a simple comparison and summary.
"For/F" is often used to parse text and read strings. In terms of division of labor,
In the FOR command statement parameter F, the most difficult to understand is the delims and tokens two options, this article simple to make a comparison and summary.
"for/f" is often used to parse text and read strings. In division, DELIMS is
(iv) TOKENS=X,Y,M-N extraction column
Format:
for/f "Tokens=x,y,m-n"%%i In (COMMAND1) do Command2
Usage:
Summary of the sentence: Extract the column.
Popular speaking, together to extract the contents of the section m of each line.
Therefore,
Compare the following two sections
CodeDifference in execution results:
1,
@ Echo off
For/F "delims =" % I in (test.txt) Do echo/% I/
Pause
2,
@ Echo off
For/F "tokens = *" % I in (test.txt) Do echo/% I/
Pause
The content of test.txt is
Compare the results of the following two-paragraph code:
1,
@echo off
for/f "delims="%%i in (test.txt) do echo/%%i/
Pause
2,
@echo off
for/f "tokens=*"%%i in (test.txt) do echo/%%i/
Pause
The content of Test.txt is: ABC. There are several spaces
Features of the script:(1) separate the current path name where the script is located with "\"(2) The separated elements into a variable of 10 letters in the A-j interval, if the directory does not have so many levels, the value of the relevant
Delete a file in a certain format in the directory]
For/r f: \ study % I in (*. o) do del % I
DOS loop: One of the bat/batch processing for commands IN the format of "FOR [parameter] % variable name IN (related file or command)" at a.m: execute
Format: for [parameter]% variable name in (related file or command) do execution command
Function: Executes specific commands on one or a set of files, strings, or on each object in the result of a command to achieve the desired result.Note: When
-- This article comes from TTT blog: http://www.yoyotao.net/ttt/, original address: http://www.yoyotao.net/ttt/post/139.html
Preface:Although it was a bit of research on batch processing in the past, I have never understood the for command
Quick view of computer parameter configuration informationSave the code directly to bat and execute it directly.Mainly includes the following computer details:System information, DisplaycardMother Board, Hard Disk, Network CardSoftware information,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.