代码未测试:- @echo off&setlocal enableDelayedExpansion
- set "e=a.txt"
- set "f=c.xml"
- set "h=b"
- for /f "usebackq skip=1 tokens=1-3 delims=月日时" %%a in ("%e%") do (
- set b=%%b&set c=%%c
- call:b "%%a"
- goto:a
- )
- :a
- set a_=0%a%&set b_=0%b%&set c_=0%c%
- move "%e%" "%b%\tp%date:~0,4%%a_:~-2%%b_:~-2%%c_:~-2%.txt"
- (
- echo;^<?xml version="1.0" encoding="utf-8" ?^>
- echo;- ^<files^>
- echo;^<file year="%date:~0,4%" month="%a%" day="%b%" name="想来就来是" url="http://10.10.10.10/tp%date:~0,4%%a_:~-2%%b_:~-2%%c_:~-2%.txt" /^>
- for /f "usebackq skip=2 delims=" %%a in ("%f%") do (
- set g=%%a
- if /i "!g:~0,10!"=="<file year" echo;!g!
- )
- echo;^</files^>
- )>$tmp
- move $tmp "%f%"
- exit
- :b
- set "a=%~1"
- if "%a:~1%"=="" goto:eof
- set/a d=%a:~-2,1% 2>nul
- if "%d%"=="%a:~-2,1%" (set a=%a:~-2%) else set a=%a:~-1%
复制代码
|