@echo off
rem configuration.ini content
::LOG_DIR=
::LOG_NAME=::FILE1=::DAY1=
::FILE2=::DAY2=
rem read configuration variable from .ini file
for /f "skip=1 tokens=1,2 delims==" %%a IN (configuration.ini) DO (
set %%a=%%b
)
rem initial log file
if not exist %LOG_NAME% (
md %LOG_DIR%
)
setlocal enabledelayedespansion
for /l %%i in (1,1,50) do (
if "!F%%i!" neq "" (
echo day is !DAY%%i! >> %LOG_NAME%
rem get date before !DAY%%i! days
rem integer calculate
set /a DaysAgo=!DAY%%i! - 1
call :DateToDays %date:~0,4% %date:~5,2% %date:~8,2% PassDays
set /a PassDays-=!DaysAgo!
:DaysToDate !PassDays! DstYear DstMonth DstDay
set DstDate=!DstYear!/!DstMonth!/!DstDay!
echo delete !F%%i! before !DstDate! >> %LOG_NAME%
for %%j in (!F%%i!) do (
echo file name is %%j >> %LOG_NAME%
echo last update time of %%j is %%~ti >> %LOG_NAME%
if %%~tj lss !DstDate! (
del %%j /f/s >> %LOG_NAME%
) else (
echo skip file %%j >> %LOG_NAME%
)
)
)
)
//below codes are copy from other place :DateToDays %yy% %mm% %dd% days setlocal ENABLEEXTENSIONS setsetyy=%1&set mm=%2&set dd=%3if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)set /a dd=100%dd%%%100,mm=100%mm%%%100set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633endlocal&set %4=%j%&goto :EOF:DaysToDate %days% yy mm ddsetlocal ENABLEEXTENSIONSset /a a=%1+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=aset /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)endlocal&set %2=%yy%&set %3=%mm%&set %4=%dd%&goto :EOF