Reputation: 195
I need some help. I want to execute for loop with if-else statement but i got some error. This is my code
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))
The output is
< was unexpected at this time
Upvotes: 0
Views: 225
Reputation: 79982
Your error report is incorrect. The output you are receiving is
( was unexpected at this time
You can't validly pipe output into a for
statement. Change your code to
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))
Upvotes: 1