I have a rather simple copy and paste batch job. That checks for a more recent file and overwrites it.

I was trying to take a single COPY and copy it to a second directory.

In simple, this Batch is to replace Files on a System (Upgrade) But i would also like a copy of all files replaced in one folder. As my Xcopy is checking Datestamp prior to replacing. Then i cannot use the Same command again to copy to an additional directory

(I only want replaced / more recent files in a additional directory)

xcopy "\\DIR1\e\DIR2\DIR3" C:\ROot\System /d /y /r
xcopy "\\DIR1\e\DIR6\DIR8" C:\ROot\System /d /y /r
xcopy "\\DIR1\e\DIR5\DIR6" C:\ROot\System /d /y /r
xcopy "\\DIR1\e\DIR4\DIR2" C:\ROot\System /d /y /r

So only if the file is more recent, is it replaced. How can i use the files its replaced and put them into a Upgrade folder for example:

xcopy "\\DIR1\e\DIR2\DIR3" C:\ROot\System C:\ROot\System\Upgradefile /d /y /r

i.e. C:\ROot\System\Upgradefile would be the additional folder all files are copied to that where replaced in C:\ROot\System

Just incase: /d=(Date) /y=Overwrite file is more recent /r=Overwrite Read only

  • 1
    If I read this correctly you want to move in new files, but make a backup copy of the previous version for files that are being replaced. I'm pretty sure this cannot be done with XCOPY, and not in any simple batch command that I know if. You might try a VBscript. Check out this article for ideas. social.technet.microsoft.com/Forums/scriptcenter/en-US/… – Tom Cee Jun 8 '17 at 19:01

Your Answer

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

Browse other questions tagged or ask your own question.