Computing.Net > Forums > Programming > Copy modified files every 5 mins

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.

Copy modified files every 5 mins

Reply to Message Icon

Name: harrisrohan
Date: November 9, 2009 at 07:22:00 Pacific
OS: Windows 2003
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 9, 2009 at 07:59:31 Pacific
Reply:

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


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

M2


0

Response Number 2
Name: harrisrohan
Date: November 9, 2009 at 08:04:26 Pacific
Reply:

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?


0

Response Number 3
Name: Mechanix2Go
Date: November 9, 2009 at 08:12:17 Pacific
Reply:

xcopy /m


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

M2


0

Response Number 4
Name: harrisrohan
Date: November 9, 2009 at 08:20:22 Pacific
Reply:

How exactly does this work and is it different from /M?


0

Response Number 5
Name: nbrane
Date: November 9, 2009 at 10:00:12 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: harrisrohan
Date: November 9, 2009 at 10:11:11 Pacific
Reply:

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


0

Response Number 7
Name: harrisrohan
Date: November 9, 2009 at 11:52:27 Pacific
Reply:

The xcopy /m worked. Thanks a million


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Copy modified files every 5 mins

Check if file is copied www.computing.net/answers/programming/check-if-file-is-copied/20217.html

Progress bar in batch file www.computing.net/answers/programming/progress-bar-in-batch-file/14919.html

batch to check last modified file www.computing.net/answers/programming/batch-to-check-last-modified-file/16351.html