批处理命令将检查一个文件的修改日期。如果修改的日期等于当前日期,那么它将通过创建当前日期的文件夹将文件复制到不同的位置。我使用了以下代码:
@echo off
set currentDate=%date%
SET filename="C:\Documents and Settings\302444\Desktop\inventory.txt"
FOR %%X IN (%filename%) DO SET filedatetime=%%~tX
pause
if %filedatetime:~0, 10% == %currentDate%
pause
(ROBOCOPY C:\Documents and Settings\302444\Desktop C:\Documents and Settings\302444\Desktop\IMP\%date:~-4,4%%date:~-10,2%%date:~-7,2% inventory.txt
pause
)
if %filedatetime:~0, 10% LSS %currentDate%
(echo file not updated
pause
)
但是 if 语句在这里不起作用。请给我同样的建议