标题: [文本处理] [已解决]批处理截取指定字符间字符 [打印本页]
作者: smss 时间: 2021-5-25 16:42 标题: [已解决]批处理截取指定字符间字符
截取<ARCH>9</ARCH>之间字符 不要第三方和PS可以截取到吗- <WIM><TOTALBYTES>2041944162</TOTALBYTES><IMAGE INDEX="1"><DIRCOUNT>22623</DIRCOUNT><FILECOUNT>78630</FILECOUNT><TOTALBYTES>11198019561</TOTALBYTES><HARDLINKBYTES>5313184735</HARDLINKBYTES><CREATIONTIME><HIGHPART>0x01D72D48</HIGHPART><LOWPART>0xC1239A12</LOWPART></CREATIONTIME><LASTMODIFICATIONTIME><HIGHPART>0x01D74D48</HIGHPART><LOWPART>0x38E79118</LOWPART></LASTMODIFICATIONTIME><WIMBOOT>0</WIMBOOT><WINDOWS><ARCH>9</ARCH><PRODUCTNAME>Microsoft® Windows® Operating System</PRODUCTNAME><EDITIONID>ProfessionalWorkstation</EDITIONID><INSTALLATIONTYPE>Client</INSTALLATIONTYPE><SERVICINGDATA><GDRDUREVISION>0</GDRDUREVISION><PKEYCONFIGVERSION>10.0.19041.1;2016-01-01T00:00:00Z</PKEYCONFIGVERSION><IMAGESTATE>IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE</IMAGESTATE></SERVICINGDATA><PRODUCTTYPE>WinNT</PRODUCTTYPE><PRODUCTSUITE>Terminal Server</PRODUCTSUITE><LANGUAGES><LANGUAGE>zh-CN</LANGUAGE><FALLBACK LANGUAGE="zh-CN">en-US</FALLBACK><DEFAULT>zh-CN</DEFAULT></LANGUAGES><VERSION><MAJOR>10</MAJOR><MINOR>0</MINOR><BUILD>19043</BUILD><SPBUILD>985</SPBUILD><SPLEVEL>0</SPLEVEL><BRANCH>vb_release</BRANCH></VERSION><SYSTEMROOT>WINDOWS</SYSTEMROOT></WINDOWS><NAME>Windows 10 专业工作站版(Admin)</NAME><DESCRIPTION>Windows 10 专业工作站版(Admin)</DESCRIPTION><FLAGS>Professional</FLAGS><DISPLAYNAME>Windows 10 专业工作站版(Admin)</DISPLAYNAME><DISPLAYDESCRIPTION>Windows 10 专业工作站版(Admin)</DISPLAYDESCRIPTION></IMAGE><IMAGE INDEX="2"><DIRCOUNT>23067</DIRCOUNT><FILECOUNT>80875</FILECOUNT><TOTALBYTES>11578277650</TOTALBYTES><HARDLINKBYTES>5503421812</HARDLINKBYTES><CREATIONTIME><HIGHPART>0x01D72D48</HIGHPART><LOWPART>0xC1239A12</LOWPART></CREATIONTIME><LASTMODIFICATIONTIME><HIGHPART>0x01D74D48</HIGHPART><LOWPART>0x7F484738</LOWPART></LASTMODIFICATIONTIME><WIMBOOT>0</WIMBOOT><WINDOWS><ARCH>9</ARCH><PRODUCTNAME>Microsoft® Windows® Operating System</PRODUCTNAME><EDITIONID>ProfessionalWorkstation</EDITIONID><INSTALLATIONTYPE>Client</INSTALLATIONTYPE><SERVICINGDATA><GDRDUREVISION>0</GDRDUREVISION><PKEYCONFIGVERSION>10.0.19041.1;2016-01-01T00:00:00Z</PKEYCONFIGVERSION><IMAGESTATE>IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE</IMAGESTATE></SERVICINGDATA><PRODUCTTYPE>WinNT</PRODUCTTYPE><PRODUCTSUITE>Terminal Server</PRODUCTSUITE><LANGUAGES><LANGUAGE>zh-CN</LANGUAGE><FALLBACK LANGUAGE="zh-CN">en-US</FALLBACK><DEFAULT>zh-CN</DEFAULT></LANGUAGES><VERSION><MAJOR>10</MAJOR><MINOR>0</MINOR><BUILD>19043</BUILD><SPBUILD>985</SPBUILD><SPLEVEL>0</SPLEVEL><BRANCH>vb_release</BRANCH></VERSION><SYSTEMROOT>WINDOWS</SYSTEMROOT></WINDOWS><NAME>Windows 10 专业工作站版</NAME><DESCRIPTION>Windows 10 专业工作站版</DESCRIPTION><FLAGS>Professional</FLAGS><DISPLAYNAME>Windows 10 专业工作站版</DISPLAYNAME><DISPLAYDESCRIPTION>Windows 10 专业工作站版</DISPLAYDESCRIPTION></IMAGE></WIM>
复制代码
- for /f "tokens=2 delims=></" %%i in ('findstr /i ARCH 1.txt^|findstr ARCH') do echo %%i
复制代码
作者: yhcfsr 时间: 2021-5-25 17:21
- @echo off
- for /f "useback delims=" %%a in ("0.txt") do (
- set "str=%%a"
- setlocal enableDelayedExpansion
- if "!str:ARCH=!" neq "!str!" set "str=!str:*<ARCH>=!"
- for /f "delims=<" %%b in ("!str!") do echo;%%b
- endlocal
- )
复制代码
作者: smss 时间: 2021-5-25 17:44
本帖最后由 smss 于 2021-5-25 18:13 编辑
wimlib生成utf-16 批处理读不到
大神来科普下为什么下面这样可以- @echo off&chcp 65001
- wimlib-imagex.exe info install.esd --xml>1.txt
- for /f "delims=" %%a in ('type 1.txt') do (
- set "str=%%a"
- setlocal enableDelayedExpansion
- if "!str:ARCH=!" neq "!str!" set "str=!str:*<ARCH>=!"
- for /f "delims=<" %%b in ("!str!") do echo;%%b
- endlocal
- )
- pause
复制代码
这样不可以- @echo off&chcp 65001
- for /f "delims=" %%a in ('wimlib-imagex.exe info install.esd --xml') do (
- set "str=%%a"
- setlocal enableDelayedExpansion
- if "!str:ARCH=!" neq "!str!" set "str=!str:*<ARCH>=!"
- for /f "delims=<" %%b in ("!str!") do echo;%%b
- endlocal
- )
- pause
复制代码
作者: xp3000 时间: 2021-5-25 20:53
- @if(0)==(0) echo off
- @for /f "delims=" %%i in ('type 1.txt^|cscript -nologo -e:jscript "%~f0"') do (
- echo %%i
- )
- pause&exit /b
- @end
- WSH.echo(WSH.StdIn.ReadAll().match(/[^>]+(?=<\/ARCH>)/).join('\r\n'));
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |