2016年10月24日 星期一

Robocopy 指令範例參考 (MIR問題很多,小心使用

http://bit.ly/2eB5PBZ

The /MIR switch is NOT a two way synchronization.  Right from the Microsoft documentation, it tells you /MIR is /e + /purge.  It does not delete files from the source.  The /MOV option DOES delete files from the source because you are moving them from the source to the destination.

C:\>robocopy C:\cmdCheckCaMainPID c:\Temp /s *.txt /MIR


 robocopy c:\Sourcepath c:\Destpath /E /XC /XN /XO
To elaborate:
  • /E makes Robocopy recursively copy subdirectories, including empty ones.
  • /XC excludes existing files with the same timestamp, but different file sizes. Robocopy normally overwrites those.
  • /XN excludes existing files newer than the copy in the source directory. Robocopy normally overwrites those.
  • /XO excludes existing files older than the copy in the source directory. Robocopy normally overwrites those.

With the Changed, Older, a

Set mm=%date:~4,2%
Set dd=%date:~7,2%
Set yyyy=%date:~10,4%
Set Year=%date:~10,4%
robocopy C:\Temp\VAE C:\Temp\VAE_Archive /MIR >> c:\Temp\%Year%-%mm%-%dd%-%yyyy%.log


set tdate=%date: =%
set tdate=%tdate:/=%
set ttime=%time::=%
set ttime=%ttime:.=%
set ttime=%ttime: =%
robocopy C:\Temp\VAE C:\Temp\VAE_Archive /MIR >> c:\Temp\%tdate%-%ttime%.log