Computing.Net > Forums > Programming > Files Modified Batch...

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Files Modified Batch...

Reply to Message Icon

Name: Aaflac
Date: August 21, 2008 at 20:26:57 Pacific
OS: XP
CPU/Ram: 1024MB
Product: Compaq
Comment:

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 off

setlocal


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 + 0

if /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 SET31

goto 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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 21, 2008 at 21:05:00 Pacific
Reply:

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Files Modified Batch...

batch change file modified date www.computing.net/answers/programming/batch-change-file-modified-date/17132.html

get 3rd line frm EOFof txt file by batch www.computing.net/answers/programming/get-3rd-line-frm-eofof-txt-file-by-batch-/19022.html

create batch file www.computing.net/answers/programming/create-batch-file/16262.html