@echo off&setlocal enabledelayedexpansion
if exist "123.bat" del /q /f /a "123.bat"
if exist "123.txt" del /q /f /a "123.txt"
mode con: cols=53 lines=10&color 0e
set YE=%date:~0,4%
set MO=%date:~5,2%
set DA=%date:~8,2%
set DG=1
set/a vY1=%YE% %% 400
set/a vY2=%YE% %% 4
set/a vY3=%YE% %% 100
if %vY1%==0 (set var=true) else (if %vY2%==0 (if %vY3%==0 (set var=false) else (set var=true)) else (set var=false))
set LY=%YE%
set LM=%MO%
if %DA:~0,1%==0 (set DA=%DA:~1,1%)
if %DA% GTR %DG% (set/a LD=%DA%-%DG%) else (
if %MO%==01 (set/a LY=%YE%-1) & (set/a LM=12+%MO%-1) & (set/a LD=31+%DA%-%DG%) else (
set/a LM=%MO%-1
if %MO%==03 (if %var%==false (set/a LD=28+%DA%-%DG%) else (set/a LD=29+%DA%-%DG%))
for %%a in (02 04 06 08 09 11) do (if "%MO%"=="%%a" (set/a LD=31+%DA%-%DG%))
for %%b in (05 07 08 10 12) do (if "%MO%"=="%%b" (set/a LD=30+%DA%-%DG%))))
if %LM% LSS 10 set LM=0%LM:~-1%
if %LD% LSS 10 set LD=0%LD:~-1%
for /l %%a in (0 1 9) do set #%%a=a
set /p file=请把你要处理的文本文件拖到本窗口或手动输入路径文件名:
set "str=%file%"
set "str=!str:"=!"
set file=!str!
for /f "delims=" %%i in ('type "%file%"') do (
set "str=%%i"
set "stra=%%i"
set "str=!str:,=!"
set "str=!str:;=!"
set "str=!str: =!"
set n=0&set "var="
for /l %%a in (0 1 9) do set str=!str:%%a= %%a !
for %%a in (!str!) do (
if defined #%%a (set var=!var!%%a&set /a n+=1) else set var=&set n=0
if !n! equ 8 echo !var!>>123.txt&set var=&set n=0
))
for /f "delims=" %%a in ('type "%file%"') do (
set "str=%%a"
for /f "delims=" %%i in (123.txt) do (
set str=!str:%%i=%LY%%LM%%LD%!
)
echo !str!>>123.bat
)
del /q /f /a "123.txt"
start 123.bat
exit
我按你上面的日期格式给你修改。
这实在不是批处理干的事情,楼主硬要批处理,看在楼主的分的份上我只好给你了,就是太小气了才有5分。如果肯多加点分将不胜感激。如果日期格式不对记得给我说。