```
:: Now it's moving only one file at a time.
:: If there are three or more files to compare, the one moved may not be the most recent.
:: Can only handle files from 2000 to 2099.
@echo off&set a=1&set b=1
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%a in ('dir/b *.txt') do call :ss "%%a"
rem +Third line content=file name
for /f "tokens=1-4 delims=_=" %%a in ('set _') do set +%%d=!+%%d!_%%a
rem __Serial number=file name first line content second line content
for /f "tokens=2* delims=_" %%a in ('set +') do (
if not "%%b"=="" set __!a!=%%a_%%b&set/a a+=1
)
set __>nul 2>nul||echo.&&echo No files to move&&echo.&&pause&&exit
:loop
for /f "tokens=1* delims==_" %%a in ('set __!b!') do set qua=%%b
for /f "tokens=1,2 delims=_" %%i in ("!qua!") do set qua1="%%i"&set qua2="%%j"
for /f "tokens=1-3 delims=" %%c in (!qua1!) do set wjm="%%c"&set dyh=%%d&set deh=%%e
for /f "tokens=1-3 delims=" %%c in (!qua2!) do set wj="%%c"&set dyhr=%%d&set dehs=%%e
call :duibi
set /a b+=1
if defined __!b! goto loop
rem Move files
if not exist c:\456 md c:\456
cls&echo\&echo The following are the files moved......&echo\
for /f "tokens=2 delims==" %%a in ('set ok^|sort') do (
echo %%a
move %%a c:\456
)
echo.&pause
start "" "c:\456"
exit
rem Set the specified content of the first three lines of the file as variables Format: _file name=first line content second line content third line content
:ss
set ls=0
rem If the operation is not successful, delete the space after delims= in the following line and enter a tab key.
for /f "tokens=2 delims= " %%b in ('findstr .* %1') do (
set/a ls+=1
if !ls! lss 4 (set "_%~1=!_%~1!_%%b") else goto :eof
)
goto :eof
rem Judge date and time
:duibi
set/a ook+=1
if "!dyh!"=="!dyhr!" (
if !deh! leq !dehs! (set ok!ook!=!wj!) else (set ok!ook!=!wjm!)
goto :eof
)
for /f "tokens=1-3 delims=/" %%o in ("!dyh!") do set nian=20%%q&set yue=%%o&set ri=%%p
for /f "tokens=1-3 delims=/" %%o in ("!dyhr!") do (
set ni_an=20%%q&set y_ue=%%o&set r_i=%%p
)
if !nian!-!yue!-!ri! lss !ni_an!-!y_ue!-!r_i! (
set ok!ook!=!wj!&goto :eof
) else set ok!ook!=!wjm!
goto :eof
```
:: Now it's moving only one file at a time.
:: If there are three or more files to compare, the one moved may not be the most recent.
:: Can only handle files from 2000 to 2099.
@echo off&set a=1&set b=1
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%a in ('dir/b *.txt') do call :ss "%%a"
rem +Third line content=file name
for /f "tokens=1-4 delims=_=" %%a in ('set _') do set +%%d=!+%%d!_%%a
rem __Serial number=file name first line content second line content
for /f "tokens=2* delims=_" %%a in ('set +') do (
if not "%%b"=="" set __!a!=%%a_%%b&set/a a+=1
)
set __>nul 2>nul||echo.&&echo No files to move&&echo.&&pause&&exit
:loop
for /f "tokens=1* delims==_" %%a in ('set __!b!') do set qua=%%b
for /f "tokens=1,2 delims=_" %%i in ("!qua!") do set qua1="%%i"&set qua2="%%j"
for /f "tokens=1-3 delims=" %%c in (!qua1!) do set wjm="%%c"&set dyh=%%d&set deh=%%e
for /f "tokens=1-3 delims=" %%c in (!qua2!) do set wj="%%c"&set dyhr=%%d&set dehs=%%e
call :duibi
set /a b+=1
if defined __!b! goto loop
rem Move files
if not exist c:\456 md c:\456
cls&echo\&echo The following are the files moved......&echo\
for /f "tokens=2 delims==" %%a in ('set ok^|sort') do (
echo %%a
move %%a c:\456
)
echo.&pause
start "" "c:\456"
exit
rem Set the specified content of the first three lines of the file as variables Format: _file name=first line content second line content third line content
:ss
set ls=0
rem If the operation is not successful, delete the space after delims= in the following line and enter a tab key.
for /f "tokens=2 delims= " %%b in ('findstr .* %1') do (
set/a ls+=1
if !ls! lss 4 (set "_%~1=!_%~1!_%%b") else goto :eof
)
goto :eof
rem Judge date and time
:duibi
set/a ook+=1
if "!dyh!"=="!dyhr!" (
if !deh! leq !dehs! (set ok!ook!=!wj!) else (set ok!ook!=!wjm!)
goto :eof
)
for /f "tokens=1-3 delims=/" %%o in ("!dyh!") do set nian=20%%q&set yue=%%o&set ri=%%p
for /f "tokens=1-3 delims=/" %%o in ("!dyhr!") do (
set ni_an=20%%q&set y_ue=%%o&set r_i=%%p
)
if !nian!-!yue!-!ri! lss !ni_an!-!y_ue!-!r_i! (
set ok!ook!=!wj!&goto :eof
) else set ok!ook!=!wjm!
goto :eof
```
致精致简!
