Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File using FORFILES to copy files within the last two weeks

Status
Not open for further replies.

bmacbmac

IS-IT--Management
Jan 26, 2006
392
US
Hi,

Each night I would like to copy files that have been modified within the last two weeks... I have been trying the FORFILES option:

Code:
FORFILES -p v:\copy1 /d +14 -m *.zip -c "CMD /C XCOPY v:\copy1\@FILE v:\copy2"

But I get an error that no files match my criteria. I think the problem is with the +14. If I use -14 it will copy files OLDER than 14 days, but I need newer than 14 days. Anyone see what my problem is?

Thanks!
 
hmmmm, tried that but same error: No files found with the specified search criteria. Thanks for that link, I'll check it out.

I should open this up and see if anyone else has a FORFILES alternative I should use to copy only files modified or created within the last 14 days?

 
In the code sample you gave I found you need to change the /d to -d AND remove some of the spaces
Code:
FORFILES -pv:\copy1 -d+14 -m*.zip -c"CMD /C XCOPY v:\copy1\@FILE v:\copy2"
I tested using forfiles.exe downloaded from the link suggested by Simon. You click on the word Update that is in blue and it will lead you here:

ftp://ftp.microsoft.com/ResKit/y2kfix/x86
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top