批处理:带有 IF ELSE 的 FOR 循环
BATCH: FOR LOOP with IF ELSE
我需要一些帮助。我想用 if-else 语句执行 for 循环,但出现了一些错误。
这是我的代码
mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" | FOR /F %%D IN ('C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))
输出为
< was unexpected at this time
您的错误报告不正确。您收到的输出是
( was unexpected at this time
您无法将输出有效地传送到 for
语句中。将您的代码更改为
FOR /F %%D IN ('mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" ^| C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))
我需要一些帮助。我想用 if-else 语句执行 for 循环,但出现了一些错误。 这是我的代码
mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" | FOR /F %%D IN ('C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))
输出为
< was unexpected at this time
您的错误报告不正确。您收到的输出是
( was unexpected at this time
您无法将输出有效地传送到 for
语句中。将您的代码更改为
FOR /F %%D IN ('mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" ^| C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))