不知道用FINDSTR如何达到这样的效果,我是用正则表达式实现的。
首先,把下面的文件存到OUD.VBS:- FUNCTION READ4(FPATH)
- DIM ADOS
- SET ADOS = CREATEOBJECT("ADODB.STREAM")
-
- WITH ADOS
- .CHARSET = "UTF-8"
- .TYPE = 2
- .OPEN
- .LOADFROMFILE FPATH
- READ4 = .READTEXT
- .CLOSE
- END WITH
- SET ADOS = NOTHING
- END FUNCTION
-
- SUB MAIN4(SEARCH, FPATH)
- DIM REGEX, MATCH, MATCHES
- SET REGEX = NEW REGEXP
- REGEX.PATTERN = SEARCH & "........"
- SET MATCHES = REGEX.EXECUTE(READ4(FPATH))
- WSCRIPT.ECHO MATCHES(0)
- END SUB
-
- MAIN4 WSCRIPT.ARGUMENTS(0), WSCRIPT.ARGUMENTS(1)
复制代码 然后,把原来代码的第7行(findstr)换为:- findstr /s /m "3101DF05" "%%a\*.xml" > OUDTMP12421.TXT
- SET /P DAT=<OUDTMP12421.TXT
- CSCRIPT OUD.VBS //NOLOGO "3101DF05" %DAT%
复制代码 这三行的作用是把原先FINDSTR的输出存到一个临时文件,然后调用VBS。VBS中用正则表达式来提取你要的字符。 |