我正在编写一个批处理文件,其执行方式如下:
这是我到目前为止所拥有的:
@echo off
set currentDate=%date:~-10%
SET filename="C:\users\ani\desktop\IMP\RetailEmp.txt"
FOR %%X IN (%filename%) DO SET filedatetime=%%~tX
pause
if %filedatetime:~0,10% == %currentDate%
pause
(
ROBOCOPY C:\Users\ANI\Desktop\IMP C:\downloads\%date:~-4,4%%date:~-10,2%%date:~-7,2%,RetailEmp.txt
pause
)
pause
if not %filedatetime:~0,10% == %currentDate%
(echo file not updated
pause
)
Exit /b 0
但批处理脚本无效。我的猜测是它必须绕过if语句。
答案 0 :(得分:0)
起始(
必须与if
:
if %filedatetime:~0,10% == %currentDate%
pause
(
ROBOCOPY C:\Users\ANI\Desktop\IMP C:\downloads\%date:~-4,4%%date:~-10,2%%date:~-7,2%,RetailEmp.txt
pause
)
应该是这样的:
if %filedatetime:~0,10% == %currentDate% (
pause
ROBOCOPY C:\Users\ANI\Desktop\IMP C:\downloads\%date:~-4,4%%date:~-10,2%%date:~-7,2%,RetailEmp.txt
pause
)