I'm very new to batch scripting, but in my last question I was trying to extract a link from a line of text, specifically:
83: href="https://beepbeep.maxresdefault.rar"><img
What I want out of it is this:
https://beepbeep.maxresdefault.rar
Someone suggested using for /f
to separate the string, and I'd like to separate it every "
mark, taking only the second token, as what I want is trapped between the two ""
.
Here is what I've got:
for /f "delims=^" tokens=^2" %%G in (output2.txt) do @echo %%G %%H >> output3.txt
The batch crashes at this point, I'm guessing it's the wrong syntax, but I'm not sure where the issue is, maybe in the "
part?
See how we delim
it on double quotes, without surrounding quotes. We have already assigned the variable between the quotes to %%a
but if we did not, then to remove the double quotes from the string we expand the variable %%a
to %%~a
(see for /?
on variable expansion):
@for /f delims^=^"^ tokens^=2 %%a in (output2.txt) do @echo %%~a