usebackq term

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
john924xps
Posts: 65
Joined: 08 Jun 2012 07:48

usebackq term

#1 Post by john924xps » 27 Sep 2012 05:51

Can someone please explain to me what the usebackq term means and what it's used for?

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: usebackq term

#2 Post by abc0502 » 27 Sep 2012 05:58

"usebackq" is used to remove the double qoutes from arround a text in a for loop

have a look at this for loop:

Code: Select all

for /f "tokens=* delims=" %%a in ("C:\test.txt") Do echo %%a

see the <"C:\test.txt"> any thing between double qoutes is treated as a string so if you try this code it will display <C:\test.txt>

But if you add <usebackq> in the for loop

Code: Select all

for /f "usebackq tokens=* delims=" %%a in ("C:\test.txt") Do echo %%a

the <usebackq> will remove the double quotes around <C:\test.txt>, so the for loop will treat it as a location to the file test.txt in C:\ and will display the content of it.

I hope that clear enough

Post Reply