Can FOR command use double quote as a delimeter?

I'm trying to parse a text file using this common statement:

     for /F "tokens=1,2,3* delims= " %%a in (input.txt) do set rev=%%c

Unfortunately, my input.txt file looks like this:

     FIELD1     FIELD2      "FIELD3"

(The last field is in double-quotes)
Is there a way that I can use a DOS for command to grab just FIELD3 instead of "FIELD3" ?

Can special characters be escaped in DOS?

I'd hate to have to resort to SED or something to change the quotation marks into commas.


-Brian Adkins

Looks like I found a pre-existing answer...
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can process "field3" to field3 with

set field3=%field3:"=%

or to change the '"' to ','

set field3=%field3:"=,%

SOME special characters can be escaped in DOS (NT/2K/XP) by being prefixed by "^" - but not all - including '"'

In XP the FOR command has a backquote option - but sadly iy only applies to (list) not to the "options" which must be in double-quotes. Now had this been implemented as a for-delimiter definition rather than fixed, it would have been much more useful. But then if I was a supervisor in that area, Microsoft may have taken up my suggestion. I'm not, so they continue to ignore me.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brianadkinsAuthor Commented:

Hadn't thought about just postprocessing FIELD3 to get rid of the quotes after the fact!


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.