Batch File - Read from a text file with spaces -
i wrote batch file read text file located in specific path. loop reads text file located in folder. if same path had spaces loop can't read it. if wrap path in quotes still can't read it. path exist, checked multiple times, , confirmed loop works pathnames contain no spaces.
is i'm doing wrong, or, limitation of batch loop?
code:
for /f "tokens=* delims=" %%x in (c:\users\someuser\virtualboxlog\log.txt) set read=%%x
if path contained space example c:\users\someuser\virtualbox log\log.txt
can't read text file, if wrap quotes , folder virtualbox log existed.
the solution problem enclosing path in quotes:
"c:\users\someuser\virtualbox log\log.txt"
but problem rises: for
interprets quotet string string, not filename.
to work around this, use usebackq
keyword:
for /f "usebackq tokens=* delims=" %%x in ("c:\users\someuser\virtualbox log\log.txt") set read=%%x
Comments
Post a Comment