robocopy "D:\test01" C:\test02 /MIR /NP /R:0 /W:0 /log:C:\RandomSync\RandFilesLog.txt
C:\RandomSync\RandFilesLog.txt%date%
我的问题:
答案 0 :(得分:0)
试试这个:
Call :GetFileDateTime F stamp
for %%a in (C A) do (
robocopy "D:\test01" %%a:\test02 /MIR /NP /R:0 /W:0 /log:C:\RandomSync\RandFilesLog%stamp%.txt
)
exit /b
:GetFileDateTime Format ret
@echo off & setlocal
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%"
( ENDLOCAL
if /i "%~1"=="DT" set "%~2=%datestamp% %timestamp%"
if /i "%~1"=="TD" set "%~2=%timestamp% %datestamp%"
if /i "%~1"=="D" set "%~2=%datestamp%"
if /i "%~1"=="T" set "%~2=%timestamp%"
if /i "%~1"=="F" set "%~2=%fullstamp%"
)
exit /b