Copy modified files every 5 mins

November 9, 2009 at 07:22:00
Specs: Windows 2003
I need a bat file to run every 5 minutes and copy only the new/modified files. each time the script runs its to place the files in a new folder by date and time.

I already have a script (xcopy) that copies the files and places them in separate folders by date and time. The problem is that I am getting all all files, not just the new/modified ones. Please help


See More: Copy modified files every 5 mins

Report •


#1
November 9, 2009 at 07:59:31
:loop
xcopy src dest\/d
ping 0.0.0.1 -n 1 -w 300000
goto :loop


=====================================
Helping others achieve escape felicity

M2


Report •

#2
November 9, 2009 at 08:04:26
Thanks for the reply, but doesn't the /d string only work if you are copying to the same destination folder.

In my case I need each 5mins copy to be a copy to a separate location.

Is there a command to say copy the last 5 minutes data?


Report •

#3
November 9, 2009 at 08:12:17
xcopy /m


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
November 9, 2009 at 08:20:22
How exactly does this work and is it different from /M?

Report •

#5
November 9, 2009 at 10:00:12
it seems like you could use m2's code, then create the timestamp directory then copy all the files into the newly created timestamp dir.

setlocal enabledelayedexpansion
:loop
xcopy src dest\/d
ping 0.0.0.1 -n 1 -w 300000

set d=%date%
set d=!d:~10,4!!d:~4,2!!d:~7,2!
set t=%time%
:just use hour and minutes, if no need for sec.s
set t=!t:~0,2!!t:~3,2!
:for seconds, replace above with below
:set t=!t:~0,2!!t:~3,2!!t:~6,2!
set newdir=!d!!t!
md !newdir!
copy dest\*.* !newdir!
goto :loop

leave the items in 'dest', as they will be needed for xcopy to validate the file's modified times against. new directory created every 5 minutes as yyyymmddhhmm


Report •

#6
November 9, 2009 at 10:11:11
I need each 5 mins update in its own time stamped directory. Correct me if I am wrong, but your code has all files in one directory

Report •

#7
November 9, 2009 at 11:52:27
The xcopy /m worked. Thanks a million

Report •


Ask Question