前提:
1、已安装FastCopy.exe
2、在服务器上共享文件夹,并能访问,如 \\JCXMB\share_JC\
代码如下:
setlocal ENABLEDELAYEDEXPANSION
set "fc=D:\FastCopy\FastCopy.exe"
set "logFile=F:\sync_JC.log"
set "timestampFile=F:\锦采\timestamp.txt"
set "fromFolder=F:\锦采\*"
set "toFolder=\\JCXMB\share_JC\"
>nul ping JCXMB -n 1
if !errorlevel! equ 0 (
>>%timestampFile% echo %date% %time%
%fc% /cmd=sync /auto_close /verify /filelog=%logFile% %fromFolder% /to=%toFolder%
)
官方说明如下:
/cmd=sync Sync (Size/date),同步大小、日期不同的文件。
/auto_close Close automatically after execution is finished with no errors.
/verify Verify written files data by xxHash(MD5/SHA-1/SHA-256) (to disable, /verify=FALSE)
/filelog Write to the filelog(detail of copy/delete files).