@echo off
Turn off echoing and do not display this line.
setlocal enabledelayedexpansion
Enable variable delay.
>I.txt echo Serial number Number of times Phone number
Create the text I.txt and output the content "Serial number Number of times Phone number".
sed "s//\n/g" T.txt
Extract all numbers in the text, each group of numbers is on an independent line, and ignore all sensitive characters.
findstr ^*$
Search for numbers that meet the conditions from the result set of the sed operation, that is, numbers with 7 or more digits.
for /f "delims=" %%i in (
Parse the result set of sed and findstr.
set A=%%i
Assign the value obtained from the parsing to variable A.
if "!A:~0,3!" neq "000"
Intercept the first 3 characters of variable A, judge whether it is 000, otherwise...
if "!A:~0,2!" neq "10"
Intercept the first 2 characters of variable A, judge whether it is 10, otherwise...
if "!A:~0,4!" neq "2009"
Intercept the first 4 characters of variable A, judge whether it is 2009, otherwise... (The above 3 if statements are in logical AND.)
if "!A:~0,5!" == "17951" set A=!A:~5!
Intercept the first 5 characters of variable A, judge whether it is 17951, if yes, intercept its 6th character and all characters behind it, and assign it to variable A.
set /a A_!A!+=1
Set the variable set and count. Among them, the variable name is: A_!A! : A_ is the prefix,!A! is the latter part, obtained by the above 4 if statements.
set
Output all environment variables.
findstr "^A_"
Filter out all variables whose variable names start with A_ from the environment variables.
for /f "tokens=1,2 delims==_" %%i in (
Parse the filtered environment variables, with = and _ as the section delimiters. The variable name is assigned to %%i, and the value of the variable is assigned to %%j.
set B=00000000%%j
Add 8 zeros in front of variable %%j and assign it to variable B.
set C_!B:~-9!:%%i==
Set the variable set. The value of each variable is =. The variable name is C_!B:~-9!:%%i, where C_ is the prefix, B:~-9! is the front part, obtained by intercepting the last 9 characters of variable B, : is the middle part, used for the next statement separation, %%i is the latter part.
findstr "^C_"
Filter out all variables whose variable names start with C_ from the environment variables.
sort /r
Sort the result set of findstr, /r specifies reverse sorting.
for /f "tokens=1,2 delims==_:" %%i in (
Parse the filtered environment variables, with =, _ and : as the section delimiters. The first half of the variable name is assigned to %%i, and the second half of the variable name is assigned to %%j.
set /a C+=1
Add to the count and assign the cumulative value to variable C.
call :D %%i
Call the label :D and pass variable %%i as the first parameter %1.
>>I.txt echo !C! !E! %%j
Output variables!C!,!E! and %%j.
if!C! lss 11 (
Judge whether variable C is less than 11, if yes...
start notepad I.txt
Open the text I.txt with the notepad program and do not wait for the program to close and exit.
exit
Exit this batch processing.
set E=%1
Set the passed parameter %1 as variable E.
if "!E:~0,1!" == "0" set E=!E:~1!&goto F
Intercept the first character of variable E and judge whether it is 0. If not, exit the label :D; if it is 0, intercept the 2nd character and all characters behind it, that is, remove this 0, and assign it to variable E. Then return to label :F and repeat this operation until there are no 0s at the beginning of variable E.
[ Last edited by Hanyeguxing on 2009-9-18 at 08:02 ]