回复 13# Wedy - @echo off
- setlocal enabledelayedexpansion
- set "NewFolder=处理结果"
- if not exist "%NewFolder%" (
- md "%NewFolder%"
- )
- for %%x in (*.txt) do (
- (for /f "tokens=1* delims==" %%a in ('type "%%x"') do (
- set "RawKey=%%a"
- set "TrimKey=!RawKey: =!"
- set "CheckCurly=%%b"
- if "!CheckCurly:~0,1!" equ "{" (
- for /f "tokens=1* delims=." %%e in ("%%a") do (
- if "x%%f" neq "x" (
- call :ChangeKey "%%a" "%%b"
- ) else (
- echo %%a=%%b
- )
- )
- ) else if "!TrimKey!" equ "birth" (
- call :ChangeValue "%%~a" "%%~b"
- ) else if "!TrimKey!" equ "death" (
- call :ChangeValue "%%~a" "%%~b"
- ) else if "x%%b" neq "x" (
- echo %%a=%%b
- ) else (
- echo %%a
- )
- ))>"%NewFolder%\%%x"
- )
- goto :eof
-
- :ChangeKey
- for /f "tokens=1* delims=." %%h in ("%~1") do (
- set /a CalcYear=%%h+2697
- echo !CalcYear!.%%i=%~2
- )
- goto :eof
-
- :ChangeValue
- for /f "tokens=1* delims=." %%h in ("%~2") do (
- set /a CalcYear=%%h+2697
- echo %~1="!CalcYear!.%%i"
- )
- goto :eof
复制代码
|