![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-25 17:14 |
47,813 topics / 349,918 posts / today 0 new / 48,274 members |
| DOS批处理 & 脚本技术(批处理室) » How to write P processing that meets this function |
| Printable Version 2,686 / 17 |
| Floor16 26933062 | Posted 2007-08-19 00:57 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
```
:: 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 ``` |
|
| Floor17 joshualaw | Posted 2007-08-20 15:29 |
| 初级用户 Posts 62 Credits 132 | |
|
If there are three or more files for comparison, the one moved is not necessarily the most recent in time. Can it be done to only move the most recent one? Maybe I need to trouble you to improve it. thanks!
|
|
| Floor18 26933062 | Posted 2007-08-20 16:37 |
| 银牌会员 Posts 879 Credits 2,268 | |
|
It's too troublesome. I've lost interest in thinking about this question. Remember to state the requirements clearly at one time when asking questions in the future.
|
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |