How to put path with blanks into "for" command? Masking & quotes
Posted: 13 Jun 2022 01:39
Assume I want to execute a command like the following from within a DOS batch script:
for /F "Tokens= Usebackq" %%G in (' "D:\some\path\with blanks inside\myprog.exe" -p "......" %1') do set "....."
then I get an error like:
'D:\some\path\with' is not recognized as an internal or external command,operable program or batch file.
When I put myprog,.exe into a directory without blanks everything work.
However I prefer to have a path WITH blanks.
How can I get the command working anyway?
How can I mask the blanks?
Mind the single quote after opening bracket which should enclose all inner double quotes (from my point of view)
Similar question:
What if I want to put the path to program into a variable. The following does not work:
set pathtoprog=D:\some\path\with blanks inside
for /F "Tokens= Usebackq" %%G in (' "%pathtoprog%\myprog.exe" -p "......" %1') do set "....."
How can I code this successfully?
for /F "Tokens= Usebackq" %%G in (' "D:\some\path\with blanks inside\myprog.exe" -p "......" %1') do set "....."
then I get an error like:
'D:\some\path\with' is not recognized as an internal or external command,operable program or batch file.
When I put myprog,.exe into a directory without blanks everything work.
However I prefer to have a path WITH blanks.
How can I get the command working anyway?
How can I mask the blanks?
Mind the single quote after opening bracket which should enclose all inner double quotes (from my point of view)
Similar question:
What if I want to put the path to program into a variable. The following does not work:
set pathtoprog=D:\some\path\with blanks inside
for /F "Tokens= Usebackq" %%G in (' "%pathtoprog%\myprog.exe" -p "......" %1') do set "....."
How can I code this successfully?