Reputation: 63
I have the following batch statement:
for /f "delims=" %%x in (file.lst) do set "offendingfile=%%x"
Although for some really odd reason, when it is called it outputs:
"C:\Windows\calc.exe "
instead of
"C:\Windows\calc.exe"
Since there is a trailing space, I can't use it properly with any other statements in the batch file, does anyone know why it does this and how to fix this, as its been driving me nuts!
Upvotes: 1
Views: 124
Reputation: 4585
does your file.lst
file has a trailing space after the file name?
I checked this with file.lst having: c:\windows\calc.exe
and the output was correct, but if the file.lst file contains c:\windows\calc.exe<SPACE>
, the output is the same that you are getting (and is the expected output as well).
Upvotes: 1
Reputation: 41222
I believe that the delims=
portion of the for
statement is removing the default behavior of using spaces as delimiters. If you remove that portion, then it should remove the trailing blank:
for /f %%x in (file.lst) do set "offendingfile=%%x"
Upvotes: 0