[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] [已解决]批处理截取指定字符间字符

截取<ARCH>9</ARCH>之间字符 不要第三方和PS可以截取到吗
  1. <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>
复制代码
  1. for /f "tokens=2 delims=></" %%i in ('findstr /i ARCH 1.txt^|findstr ARCH') do echo %%i
复制代码

  1. @echo off
  2. for /f "useback delims=" %%a in ("0.txt") do (
  3. set "str=%%a"
  4. setlocal enableDelayedExpansion
  5. if "!str:ARCH=!" neq "!str!" set "str=!str:*<ARCH>=!"
  6. for /f "delims=<" %%b in ("!str!") do echo;%%b
  7. endlocal
  8. )
复制代码
1

评分人数

QQ 33892006

TOP

本帖最后由 smss 于 2021-5-25 18:13 编辑

wimlib生成utf-16 批处理读不到
大神来科普下为什么下面这样可以
  1. @echo off&chcp 65001
  2. wimlib-imagex.exe info install.esd --xml>1.txt
  3. for /f "delims=" %%a in ('type 1.txt') do (
  4. set "str=%%a"
  5. setlocal enableDelayedExpansion
  6. if "!str:ARCH=!" neq "!str!" set "str=!str:*<ARCH>=!"
  7. for /f "delims=<" %%b in ("!str!") do echo;%%b
  8. endlocal
  9. )
  10. pause
复制代码
这样不可以
  1. @echo off&chcp 65001
  2. for /f "delims=" %%a in ('wimlib-imagex.exe info install.esd --xml') do (
  3. set "str=%%a"
  4. setlocal enableDelayedExpansion
  5. if "!str:ARCH=!" neq "!str!" set "str=!str:*<ARCH>=!"
  6. for /f "delims=<" %%b in ("!str!") do echo;%%b
  7. endlocal
  8. )
  9. pause
复制代码

TOP

  1. @if(0)==(0) echo off
  2. @for /f "delims=" %%i in ('type 1.txt^|cscript -nologo -e:jscript "%~f0"') do (
  3.     echo %%i
  4. )
  5. pause&exit /b
  6. @end
  7. WSH.echo(WSH.StdIn.ReadAll().match(/[^>]+(?=<\/ARCH>)/).join('\r\n'));
复制代码
1

评分人数

TOP

返回列表