New
#11
Unfortunately it will overwrite an older version of a file in the destination folder with the latest one from the source. The OP needs to keep older versions in case of errors in the new one. File History has the ability to restore previous versions.
But you're on the right track. XCopy can be useful, particularly its /M option which only copies files with the Archive attribute set, then clears the Archive attribute. This ensure that only modified files will be copied. The /S option will copy subdirectories too, but not if they're empty.
What we need to mimic File History is to keep multiple copies in the destination folder, each under a folder with a date stamp of the time the backup was made. That's a little more complicated than a single command line and need a batch file to do it. Here's one (with help on generating the date stamp from Stack Overflow)
Code:@echo off for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%" set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%" echo datestamp: "%datestamp%" echo timestamp: "%timestamp%" echo fullstamp: "%fullstamp%" pause mkdir "D:\Destination_Folder\%fullstamp%" XCopy Source_Folder\*.* "D:\Destination_Folder\%fullstamp%" /S /M
Saved as XCopy_File_History.bat it works like this...
..and results in this.
The batch script can be run in the background via VBScript. You will not see a window.