Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 filesArcot systemsconf f.properties). It is complaining saying Environment variable C:Program FilesArcot not defined, even though I have provided quotes. How to get it working?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
576 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...