1

I created a sample bat file in order to have a back-up system. this does not show what my intention is but it demonstrates it. here is my bat file content;

xcopy C:\apps\source c:\apps\dest /D /E /C /R /H /I /K /Y

what I want is this;

I want to copy every updated file and sub-folders from source folder to dest folder. is this code is ok for that. thanks !

1
  • I recommend a source control software, as Mercurial, Git or SVN, that stores old files as revisions and you can access them to compare with current version. But you can do it with a Windows batch file, using that xcopy plus fc command to copy only modified files, but you have to have a copy of all files in the older version in another folder to compare - so it is easier to have a done solution with mentioned software.
    – kokbira
    Apr 25, 2011 at 14:24

3 Answers 3

2

Xcopy's performance and features leave a lot to be desired compared to the alternatives.

Have a look at Richcopy - it's Robocopy on steriods and also from Microsoft. Richcopy is also Multithreaded (Robocopy only became multithreaded with the Windows 7 version) and so it's throughput is quite impressive.

http://technet.microsoft.com/en-us/magazine/2009.04.utilityspotlight.aspx

http://www.servermigrator.com/blog/2009/08/11/the-easiest-way-to-prepare-richcopy-command-line-parameters/

1
  • Actually Linker3000, I don't believe Robocopy is multithreaded even on Windows 7. So Richcopy might be a better option, especially if dealing with large numbers of files. Thanks for posting!
    – Joshua
    Apr 20, 2011 at 13:37
1

You need /S /E rather than /E on it's own.

And if it's a backup system, you probably don't want to supress errors with a /C, but to react to them.

1

I recommend using robocopy, which is part of Windows 7 / Server 2008. More information here: http://en.wikipedia.org/wiki/Robocopy

This tool provides a bunch of options, not the least of which is an ability to "mirror" your locations and copy only the changes (so you don't have to do the entire file dump again, which saves a LOT of time if you are dealing with large or large numbers of files).

Example of mirror, copying only changes:

robocopy C:\data E:\data /MIR /Z

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .