Tuesday, 15 January 2013

Batch File - Read from a text file with spaces -


I wrote a batch file to read a text file located in a specific file. Reads from a text file located in a folder for the loop. If this path can not be read loop for spaces. Even if I wrap the path in quotation marks, it still can not read it. The path exists, I checked several times and confirmed that the loop works only with path names in which there is no empty space.

Is there anything that I am doing wrong, or is there a limit to this batch for loop?

Code:

  FOR / F "tokens = * delims =" %% x in (C: \ users \ someuser \ VirtualBoxLog \ Log.txt) SET read = %% x  

If this path contains one place for example then C: \ users \ someuser \ virtualBox log \ log.txt < / Code> It can not read from the text file, even though I have it in the quote and the folder VirtualBox logs existed.

Fix the problem in your quotation marks:

 < Code> "C: \ user \ someuser \ virtualbox log \ log.txt"  

But now another problem increases: for as a quote Explains the form of a quote as a coat, not as a file name.

To work around this, usebackq keyword:

usebackq token = * delimits = "%% x" ("C: \ users \ someuser \ virtualbox log \ log.txt") SE SE = %% x

No comments:

Post a Comment