Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am not a programmer by any chance, and I am looking for a batch file to identify dirs/files that have been modified within the last month.
The following is supposed to copy files/dirs that have been changed within the last day.How can I change this to be used in XP, and just identify dirs/files that have been changed within the last month? No need to copy them.
Thanks for your help!!
@echo offsetlocal
for /F "tokens=2-4 delims=/ " %%f in ('date /t') do (
set mm=%%f
set dd=%%g
set yyyy=%%h
)REM Substract your 1 day here
set /A dd=1%dd% - 100 - 1
set /A mm=1%mm% - 100 + 0if /I %dd% GTR 30 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
if %mm%==12 goto SET31goto ERROR
:SET31
set /A dd=31 + %dd%
goto DONE
:SET30
set /A dd=30 + %dd%
goto DONE
:LEAPCHK
set /A tt=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29
:SET28
set /A dd=28 + %dd%
goto DONE
:SET29
set /A dd=29 + %dd%
:DONE
echo xcopy c:\source c:\dest /E /Y /D:%mm%-%dd%-%yyyy%
:EXIT

LOL
You can peruse several hundred threads here on the general subjuct of 'date math' in batch. None has a happy ending.
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |