【发布时间】:2018-04-27 01:45:15
【问题描述】:
相关代码如下:
cd /d %~dp0
if exist filename.txt (
echo %date% %time% *** text... >> filename2.txt
echo ==============================
echo === text....... ===
echo === text....... ===
echo === text....... (text...) ===
echo === text (text...
echo === text...).
:loop
set /p "varx= text: "
if "%varx%" neq "xxxx" goto loop
... more script...
)
已经搜索了高和低的解决方案......
在此处指向 If 语句分组的方向: https://www.petri.com/forums/forum/windows-scripting/general-scripting/57625-if-exists-file-was-unexpected-at-this-time - 不行
指出了 If 块中的循环问题的方向,此处: (Windows batch) Goto within if block behaves very strangely - 不行
被指出使用@setlocal enabledelayedexpansion 或@setlocal enableextensions 的方向(无法追踪到哪里) - 不去
尝试通过 set /p varfile="filename" 传递文件名,如果存在 %varfile% - 不成功
当然认为是代码的其他部分导致了错误 -- NO GO
问题是这个 WAS 工作了很长时间......然后我改变了我认为是一些无害的东西并且无法弄清楚问题出在哪里......
这样一个难以解决的问题......哎呀!
【问题讨论】:
标签: batch-file if-statement special-characters