Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

:loop
xcopy src dest\/d
ping 0.0.0.1 -n 1 -w 300000
goto :loop
=====================================
Helping others achieve escape felicityM2

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?

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 300000set 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 :loopleave 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

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

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |