@echo off
setlocal enabledelayedexpansion
set dir=\esp\var\log\querylogs\
for /l %%j in (1,1,4) do (
@echo %%j
NET USE \\192.168.4.9%%j\c$ /user:"administrator" "123456"
for %%i in (\\192.168.4.9%%j\c$%dir%*.*) do (
set dd=%%i
if !dd:~50,8!==!date:~0,4!!date:~5,2!!date:~8,2! ( @echo !dd!)
rem @echo !dd:~50,8!
rem @echo !date:~0,4!!date:~5,2!!date:~8,2!
)
)
pause
以上代码在if 判断那应该能取到相等条件的输出,但一点反应也没有,如果把if注释掉,运行下边两个注释掉的echo
结果明明又是相等的,好生奇怪!求助高手指出问题所在
把if语句的判断条件放在""里执行就可以了。
"!dd:~50,8!" == "!date:~0,4!!date:~5,2!!date:~8,2!"