本帖最后由 taofan712 于 2017-2-14 21:32 编辑
作业练习:- @echo off
- setlocal enabledelayedexpansion
- set /a aa=%random%%%100
- for /f "delims=" %%a in ('dir /a-d /s /b targetpath\sourcemonitor.xml') do (
- set /a aa+=1
- for /f "tokens=2 delims=><" %%b in ('find /i "</project_name>" "%%a"') do ( set target=%%b
- )
- for /f "skip=2 tokens=1,* delims=[]" %%c in ('find /i /n "</project_name>" "%%a"') do ( set line=%%c
- )
- for /f "skip=2 tokens=1* delims=[]" %%d in ('find /n /v "" "%%a"') do (
- set list=%%d
- set str=%%e
- if "!list!"=="!line!" (
- for %%f in (!target!) do (
- for %%g in (!aa!) do (
- set str=!str:%%f=%%g%%g%%g!
- echo;!str!
- )
- )
- ) else (
- echo;!str!
- )
- )
- )>>"%%~dpa_new_sourcemonitor.xml"
- rem move /y "%%~dpa_new_sourcemonitor.xml" "%%a"
- echo;完毕&pause>nul
复制代码 【缩进排版不知道对不对】 |