开发者

For /f processing filename with spaces

I want to do some processing on each line of a file.

for /f "delims=" %%i in ("%RF_PROPERTIES%") do (          
   echo %%i
)

My RF_PROPERTIES points to a file path with spaces (c:\program files\Arcot systems\conf\rf.properties). It is complaining saying Environment variable C:\Program Files\Arcot not def开发者_高级运维ined, even though I have provided quotes. How to get it working?


Try adding the usebackq option:

for /f "usebackq delims=" %%i in ("%RF_PROPERTIES%") do (          
  echo %%i
)

Explanation from the output of for /?:

usebackq - specifies that the new semantics are in force, where a back quoted string is executed as a command and a single quoted string is a literal string command and allows the use of double quotes to quote file names in file-set.


Using usebackq is a good idea - but you actually have to use them :

for /f "usebackq delims=" %%i in ( `dir "%RF_PROPERTIES%" /s /b` ) do (
  echo %%i
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜