我正在尝试运行以下批处理文件:
set HH=%time:~0,2%
set HH=%HH: =0%
IF %time:~0,2% GTR 5 (
IF %time:~0,2% LSS 21 (
FOR /F "TOKENS=1 DELIMS=:" %%A IN ('TIME/T') DO SET HH=%%A
XCOPY "D:\Sage RAM Image\Sage Data" C:\Sage-Incremental-Backup\sage-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-hour-%HH% /D /Y /E /R /K /C /H /I
"C:\Program Files\7-Zip\7z.exe" -a -pXXXX C:\Sage-Incremental-Backup\sage-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-hour-%HH%\sage-backup.zip C:\Sage-Incremental-Backup\sage-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-hour-%HH%\*
EXIT /B 0
)
)
但它一直给我错误“命令行不正确”。我认为这可能与日期变量有关,因为它们在正常的 XCOPY 操作中工作正常。
到底哪里错了?
当我回应这一行时,我得到:
"C:\Program Files\7-Zip\7z.exe" -a -p3uropeaN1 C:\Sage-Incremental-Backup\sage-2
014-06-10-hour-07\sage-backup.zip C:\Sage-Incremental-Backup\sage-2014-06-10-hou
r-07\*
答案1
看来-a
开关错了。我移除了-a
,用 just 替换a
,它就起作用了 ☺。