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 !

  • 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 '11 at 14:24

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.



| improve this answer | |
  • 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 '11 at 13:37

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.

| improve this answer | |

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.