Reputation: 89
I am wanting to transfer the result of a find command into a variable named 'String3', as below;
Set String3=0
for /L %%i in (1,1,%index%) do
echo !URL[%%i]! | find /I "%String3Search%">nul | ( !String3! )
However i get the following error;
The syntax of the command is incorrect.
The index contains the number of open websites within Internet Explorer. So the find is determining if the 'String3Search' exists.
Where am i going wrong here?
Thanks in advance.
Upvotes: 0
Views: 97
Reputation: 14300
You can use a FOR /F
command to capture the result of other commands you are running. Also note the use of parentheses.
@echo off
setlocal enabledelayedexpansion
Set "String3=0"
set "String3Search=findme"
for /L %%i in (1,1,%index%) do (
FOR /F "delims=" %%G IN ('echo !URL[%%i]! ^| find /I "%String3Search%"') DO (
set "String3=%%G"
)
)
Upvotes: 1