Script that will copy a file based on the date modified

scriptingwindows-server-2003

I need to run a script which will copy a file from one directory to another based on the date it was modified. Basically I have a database dumped into a directory on a daily basis and I want to be able to copy the database from the first of each month to a different directory so that I can delete have all the other files in the folder deleted.

Can anybody help me out?

This is a script which I would like to run on Windows Server 2003.

Thanks in advance.

Best Answer

Use Robocopy it's a built in function of the operating system the syntax should be something along the lines of this.

Robocopy “\source” "\destination" /mir /mon:1 /mot:1 /R:3 /W:10 /COPY:DAT /log:c:\tools\robolog.txt /NDL /NP /Z

create and save this as a batch file have a scheduled task run it 23 hours a day and the process kill and restart it afterwards.

here is the technet reference for all commands and functions http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx