1
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
::@pause
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. https://social.technet.microsoft.com/Forums/scriptcenter/en-US/0f8c5c6b-e453-4b7f-a36e-23c73f075e43/vbscript-backup-the-file-before-modify?forum=ITCG
– Tom Cee – 2017-06-08T19:01:40.830