Overwrite if older

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
egrimisu
Posts: 1
Joined: 01 Sep 2009 03:24

Overwrite if older

#1 Post by egrimisu » 01 Sep 2009 03:32

Hi guys, i'm brand new on the forum and obviosly i have some question in witch i hope to get answers.

c:\Live\document.txt
c:\Backup\

So, i want to make a logoff script that cals this bat file that i want to do the next thing: i want to copy document.txt from c:\live into c:\backup\ and overwrite the c:\backup\document.txt only if c:\livedocument\document.txt is older with atleat 7 days than docment.txt from backup folder. Thanks in advance

if c:\live\document.txt older than c:\backup\document.txt with atleast 7 days
copy if c:\live\document.txt c:\backup\document.txt

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 01 Sep 2009 15:25

Can be done with custom batch script -- but xcopy will already do it (not that I like xcopy), or, much better, use robocopy. Free from Microsoft in the resource kit. Great tool and it'll do exactly what you want (I'll bet).

http://ss64.com/nt/robocopy.html

http://www.microsoft.com/downloads/deta ... 8c4790cffd

Post Reply