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 defined, even though I have provided quotes. How to get it working?
Don't start or end your filename with a space, period, hyphen, or underline. Keep your filenames to a reasonable length and be sure they are under 31 characters. Most operating systems are case sensitive; always use lowercase. Avoid using spaces and underscores; use a hyphen instead.
Use quotation marks when specifying long filenames or paths with spaces. For example, typing the copy c:\my file name d:\my new file name command at the command prompt results in the following error message: The system cannot find the file specified.
There are two main ways to handle such files or directories; one uses escape characters, i.e., backslash (\<space>), and the second is using apostrophes or quotation marks. Using backslash can be confusing; it's easy and better to use quotation marks or apostrophes.
Java per se handles spaces in filenames just fine with no escaping or anything. You may be trying to access a file the user running the jvm don't have access to.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With