I have a file and I wish to use the for command to go through it. My issue is that I try to delim by double quotes character ["] and I have to escape it, so my for would look like this:
for /f tokens^=1^,2^,3^ delims^=^<^"^= %%a in ("%%i") do (
)
And I don't understand why is it that if I remove the last [^] from tokens tokens^=1^,2^,3**^**
I get an error: that delims was unexpected.
Any suggestions on how can I delim by double quotes and not have to escape every other character?
The problem is, that you use the options without enclosing quotes,
like in
FOR /F "tokens=1,2 delims=[]" ...
.
But if you want to use a quote as a delim character, you can't use the enclosing quotes anymore.
And then nearly all characters must be escaped with a caret, as ,=;<space>
are also standard token delimiters.
Even the spaces have to be escaped to create a single option token.
for /f tokens^=1^,2^,3 delims^=^<^"^= %%a
will be split into
for
- /f
- tokens=1,2,3
- delims=<"=
But the /F
expects exactly one or none option token.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With