Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Double quote used as FOR delim

248 views
Skip to first unread message

Tom Del Rosso

unread,
Jun 27, 2016, 7:24:10 AM6/27/16
to
The DELIM field is terminated with a double quote. Is there a way to
use double quote as a delimiter?

I thought of using string replacement to put another character there but
that might not work, as these long strings have a variety of characters.

--



contrex

unread,
Jun 27, 2016, 4:25:45 PM6/27/16
to
Normally FOR options are enclosed within quotes. If you want to use a quote as part of an option, then the enclosing quotes must be ditched. That means all characters that the CMD interpreter uses as token delimiters must be escaped, including space and equal sign. Also the quote needs to be escaped.


for /f tokens^=1^-3^ delims^=^" %F in ('echo "ab" "bc"') do echo f=%F g=%G h=%H

C:\Windows\System32>for /f tokens^=1^-3^ delims^=^" %F in ('echo "ab" "bc"') do echo f=%F g=%G h=%H

C:\Windows\System32>echo f=ab g= h=bc
f=ab g= h=bc



http://superuser.com/questions/514284/how-do-i-use-a-quote-as-a-for-f-delimiter-in-cmd-exe-on-windows-7

Tom Del Rosso

unread,
Jun 28, 2016, 9:22:25 AM6/28/16
to
Thanks. That reveals how CMD parses the line before giving it to FOR.
CMD needs the quotes but FOR doesn't even see them.


0 new messages