对输出结果使用 findstr 进行再处理:- (for /F "delims=" %%a in (1.txt) do (findstr /i /b /l /c:"%%a\\" 1.txt>nul||echo.%%a))>2.txt
复制代码 也就是:- @echo off&setlocal enabledelayedexpansion
- ::设置几天内
- set xing=150
- ::设置路径
- set "p=D:\rec"
- call:han %xing%
- (for /f "delims=" %%a in ('dir /s/b/ad "%p%"') do set t=%%~ta&set t=!t:-=!&if !t:~0^,8! gtr %xing% echo.%%a))>$temp$
- (for /F "delims=" %%a in ($temp$) do (findstr /i /b /l /c:"%%a\\" $temp$>nul||echo.%%a))>结果.txt
- del $temp$
- pause&exit
- :han:几天前的计算
- for /f "tokens=1-3 delims=-:/ " %%a in ("%date%") do (
- set Y=%%a&set M=%%b&set D=%%c
- if "!M:~0,1!"=="0" set M=!M:~1!
- if "!D:~0,1!"=="0" set D=!D:~1!)
- set/a D-=%1
- if %D% gtr 0 goto:gu
- :ye
- set/a M-=1
- if !M!==0 set/a Y-=1,M=12
- set/a "T=^!(M-2)","R=(^!(Y%%4)&^!^!(Y%%100))|^!(Y%%400)","C=^!(M-4)|^!(M-6)|^!(M-9)|^!(M-11)","D=T*(28+R)+C*30+(^!T&^!C)*31+D"
- if %D% leq 0 goto:ye
- :gu
- set M=0%M%&set D=0%D%&set xing=%Y%!M:~-2!!D:~-2!
复制代码
[ 本帖最后由 hanyeguxing 于 2010-5-29 17:00 编辑 ] |